最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

url rewriting - Custom taxonomy named 'tag' return 404 page

programmeradmin2浏览0评论

I registered a custom taxonomy named 'tag', code below:

add_action('init', 'reg_custom_tag');
function reg_custom_tag() {
    register_taxonomy('tag', array('my_custom_post_type'), array(
        'labels' => array(
            'name' => 'Tags',
            'singular_name' => 'Tag',
            'search_items' => 'Search Tags',
            'all_items' => 'All Tags',
            'parent_item' => 'Parent Tag',
            'parent_item_colon' => 'Parent Tag:',
            'edit_item' => 'Edit Tag',
            'update_item' => 'Update Tag',
            'add_new_item' => 'Add New Tag',
            'new_item_name' => 'New Tag Name',
            'menu_name' => 'Tags'
        ),
        'hierarchical' => false,
        'show_ui' => true,
        'show_admin_column' => false,
        'update_count_callback' => '_update_post_term_count',
        'public' => true,
        'rewrite' => false
    ));
}

I then created a few tags, for example: apple, banana, and orange. By default, the url for this taxonomy would be:

/?tag=apple

The above will give me a 404.
I have tried other options:

  1. Creating archive.php, taxonomy.php, taxonomy-tag.php, failed.
  2. Set rewrite to "true", which should activate , also failed.

The only thing I cannot explain is that, I have another custom taxonomy with the exact same settings. The only difference is the name, which is "location".

And magically, depending on the settings, both /?location=north and work flawlessly.

Can someone please advise? Thanks in advance.

发布评论

评论列表(0)

  1. 暂无评论