11

Typecho根据文章cid与字段名获取字段值

 3 years ago
source link: https://www.huhexian.com/22459.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Typecho根据文章cid与字段名获取字段值

青山 2022-01-1110:35:44评论274字

Typecho官方的主题开发文档中,很少有关于文章字段和主题设置相关的开发说明。我也是查看了一些开源主题的代码才搞懂自定义字段和主题设置的开发。这里就简单写一下文章cid与字段名获取字段值的定义和调用。

Typecho根据文章cid与字段名获取字段值

  1. function getCustom($cid, $key){
  2. $f=Typecho_Widget::widget('Widget_Archive@'.$cid,'pageSize=1&type=post', 'cid='.$cid);
  3. return $f->fields->$key;
  1. echo getCustom('文章cid', '字段名');

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK