子比主题增加精选文章按钮

jingxuan-pic-zs.webp

简单两步,代码实现:
1、将以下代码直接放到 zibllincoptionsmetabox-options.php 下方:

//META BOX SETTING
CSF::createMetabox('mrhe_jingxuan', array(
  'title'     => '精选',
  'post_type' => array('post', 'page', 'plate', 'forum_post'),
  'context'   => 'advanced',
  'data_type' => 'unserialize',
));
CSF::createSection('mrhe_jingxuan', array(
  'fields' => array(
    array(
      'title'   => __('是否精选文章', 'https://bg.leohi.top'),
      'id'      => 'jx',
      'type'    => 'Checkbox',
      'label'   => '是否精选文章',
      'default' => false // or false
    ),
  ),
));

2、将以下代码放到 zib-posts-list.php 文件中,如图位置:

if (get_post_meta($post->ID, 'jx', true)){
    $sticky .= '<badge class="img-badge right jb-red"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-hot"></use></svg> 精选</badge>';
  }

jingxuan-code-zs.webp

就这么简单,只需要在主题自带的编辑器里面点击编辑即可看见该选项(子比用户的前台没有这个功能,只能后台使用)

温馨提示:本文最新于2023-08-26 19:52:25进行了更新,某些文章内容具有时效性,若失效或有错误,请在下方留言
© 版权声明
THE END
点赞12投币 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容