PHP Wordpress自定义帖子类型注册

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Wordpress自定义帖子类型注册相关的知识,希望对你有一定的参考价值。

add_action('init', 'my_custom_init');
function my_custom_init() 
{
  $labels = array(
    'name' => _x('Books', 'post type general name'),
    'singular_name' => _x('Book', 'post type singular name'),
    'add_new' => _x('Add New', 'book'),
    'add_new_item' => __('Add New Book'),
    'edit_item' => __('Edit Book'),
    'new_item' => __('New Book'),
    'view_item' => __('View Book'),
    'search_items' => __('Search Books'),
    'not_found' =>  __('No books found'),
    'not_found_in_trash' => __('No books found in Trash'), 
    'parent_item_colon' => ''
  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  ); 
  register_post_type('book',$args);
}

以上是关于PHP Wordpress自定义帖子类型注册的主要内容,如果未能解决你的问题,请参考以下文章

php 显示wordpress注册的自定义帖子类型列表

从 Wordpress 取消注册自定义帖子类型

WordPress 自定义帖子类型存档-<帖子类型>.php 不起作用

php Wordpress - 列出所有(自定义帖子类型)帖子类别

PHP 检查当前帖子类型是否为自定义帖子类型 - WordPress

php 使用自定义帖子类型获取自定义WordPress菜单