注册自定义帖子类型wordpress
我已经在我的主题中创建了新的帖子类型,但是当我试图访问该帖子的永久链接时,它告诉我该帖子没有找到注册自定义帖子类型wordpress,wordpress,Wordpress,我已经在我的主题中创建了新的帖子类型,但是当我试图访问该帖子的永久链接时,它告诉我该帖子没有找到 function my_post_type_news() { register_post_type( 'news', array( 'label' => __('News'), 'public' => true, 'show_ui' => true,
function my_post_type_news() {
register_post_type( 'news',
array(
'label' => __('News'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'menu_position' => 5,
'rewrite' => array(
'slug' => 'news',
'with_front' => FALSE,
),
'supports' => array(
'title',
'thumbnail',
'editor',
'excerpt')
)
);
register_taxonomy('news_category', 'news', array('hierarchical' => true, 'label' => 'News Categories', 'singular_name' => 'Category', "rewrite" => true, "query_var" => true));
}
add_action('init', 'my_post_type_news');
注册分类法('news\u category','news',array('hierarchical'=>true,'label'=>'news Categories','singular\u name'=>'category','rewrite'=>true,'query\u var'=>true));
}
使用上述功能,它将工作。我已将“重写”更改为“错误”
希望有帮助。但为什么?你能给我解释一下吗?
function my_post_type_news() {
register_post_type( 'news',
array(
'label' => __('News'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'menu_position' => 5,
'rewrite' =>false,
'supports' => array(
'title',
'thumbnail',
'editor',
'excerpt')
)
);
add_action('init', 'my_post_type_news');