注册自定义帖子类型wordpress

时间:2013-02-25 08:04:50

标签: wordpress

我已经在我的主题中创建了新的帖子类型,但是当我尝试访问该帖子的固定链接时,它会告诉我该帖子未找到

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');

1 个答案:

答案 0 :(得分:0)

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')
            ) 
        );

register_taxonomy(' news_category',' news',array(' hierarchical' => true,' label' =>& #39;新闻类别',' singular_name' =>'类别',"重写" => true," query_var" => true));       }

 add_action('init', 'my_post_type_news');

使用上述功能,它将起作用。我把重写改为假。

希望它有所帮助。