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

1 回答 1

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' => 'News Categories', 'singular_name' => 'Category', "rewrite" => true, "query_var" =>真的)); }

 add_action('init', 'my_post_type_news');

使用上述功能,它会工作。我已将 rewrite 更改为 false。

希望能帮助到你。

于 2013-02-25T08:38:48.813 回答