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:

http://domain.com/?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 http://domain.com/tag/apple, 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 http://domain.com/?location=north and http://domain.com/location/north work flawlessly.

Can someone please advise? Thanks in advance.

  • did you flush rewrite rules or permalinks? wp-admin > Settings > Permalinks > click "Save Changes". – Chetan Vaghela Sep 13 at 5:06
  • I did. Still 404. My current guess is it's conflicting with the regular post "post_tag" that reserves the slug "tag". – CNVSO Sep 13 at 5:38
  • Tags already exist, and already use the /tag/ URL. You need to give it a unique name. – Jacob Peattie Sep 13 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.