在WordPress中注册新的帖子类型

时间:2012-10-08 10:55:13

标签: wordpress custom-post-type

function ms_register_blog_posts_custom_post() {
    $labels = array('name' => 'تدوينات','singular_name' => 'تدوينة','menu_name' => 'تدوينات');
    $args = array( 'public' => true, 'show_ui' => true,'labels' => $labels,  'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments' ),'capability_type' => 'post','has_archive' => true, 'query_var' => true,);
    register_post_type( 'blog', $args );
    flush_rewrite_rules();
}
add_action( 'init', 'ms_register_blog_posts_custom_post' );

我正在使用此功能注册一个新的帖子类型,当我删除flush_rewrite_rules();并前往mysite.com/blog时,它会给出一个404页面,当我保留它时它可以正常工作。但我知道你不能在你网站上的每一页访问中刷新重写规则。那我的代码出了什么问题?

0 个答案:

没有答案
相关问题