php 添加自定义帖子类型#cpt #cust
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 添加自定义帖子类型#cpt #cust相关的知识,希望对你有一定的参考价值。
// Create Custom Post Type
function register_custom_posts_init() {
$supports = array(
'title', // post title
'editor', // post content
'author', // post author
'thumbnail', // featured images
'excerpt', // post excerpt
'custom-fields', // custom fields
'comments', // post comments
'revisions', // post revisions
'post-formats', // post formats
);
$labels = array(
\!h 'name' => _x('__news__', 'plural'),
\!h 'singular_name' => _x('__news__', 'singular'),
\!h 'menu_name' => _x('__news__', 'admin menu'),
\!h 'name_admin_bar' => _x('__news__', 'admin bar'),
'add_new' => _x('Add New', 'add new'),
\!h 'add_new_item' => __('Add New __news__'),
\!h 'new_item' => __('New __news__'),
\!h 'edit_item' => __('Edit __news__'),
\!h 'view_item' => __('View __news__'),
\!h 'all_items' => __('All __news__'),
\!h 'search_items' => __('Search __news__'),
\!h 'not_found' => __('No __news__ found.'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => true,
'query_var' => true,
\!h 'rewrite' => array('slug' => '__news__'),
'has_archive' => true,
'hierarchical' => false,
);
register_post_type('news', $args);
}
add_action('init', 'register_custom_posts_init');
以上是关于php 添加自定义帖子类型#cpt #cust的主要内容,如果未能解决你的问题,请参考以下文章
php 注册多个自定义帖子类型CPT
php 在“前端布局”列表中显示“自定义帖子类型”。 Upfront隐藏'产品'CPT,因为它依赖于电子商务插件,此过滤器将显示CPT i
用户无需访问常规帖子即可访问CPT(自定义帖子类型)
php CPT的自定义帖子状态
查询自定义帖子类型并按自定义帖子类型排序
将类别添加到永久链接时,WordPress CPT 会导致 404