欢迎光临
我们一直在努力

wordpress主题添加自定义文章类型

在functions.php文件中添加以下代码:

add_action('init', 'cptui_register_my_cpt_miniblog');
function cptui_register_my_cpt_miniblog() {
register_post_type('miniblog', array(
'label' => '微博客',
'description' => '一个微博客',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'miniblog', 'with_front' => true),
'query_var' => true,
'menu_icon' => 'http://www.nixonli.com/wp-content/themes/nixonli/img/weibo.png',
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),
'taxonomies' => array('post_tag'),
'labels' => array (
  'name' => '微博客',
  'singular_name' => '微博客',
  'menu_name' => '微博客',
  'add_new' => '添加',
  'add_new_item' => '添加微博客',
  'edit' => '编辑',
  'edit_item' => '编辑微博客',
  'new_item' => '新微博客',
  'view' => '查看',
  'view_item' => '查看微博客',
  'search_items' => '搜索微博客',
  'not_found' => '未找到',
  'not_found_in_trash' => '在回收站中没有找到',
  'parent' => '父级',
)
) ); }
窗外天空
关注公众号『窗外天空』

获取更多建站运营运维新知!
互联网创业、前沿技术......

赞(0) 打赏
文章名称:《wordpress主题添加自定义文章类型》
文章链接:https://www.nixonli.com/17681.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏