I've been struggling to get the permalink structure to be correct on my custom post types (at least, I believe this is what I believe the problem is at this point - please correct me if you think that's not the case). I'm using the CPT UI plugin.

I'm using <?php the_tags(); ?> on the CPT posts/associated page to display a linked list of each post's associated tags. The link that this generates is "mysite/tag/thetag", when I believe what it should be is "mysite/customposttype/tag/thetag" (or something similar). Additionally, if I go to the URL that I would expect to exist based on my understanding, nothing shows up.

The link to "mysite/tag/thetag" just displays a "Not Found" with a search bar, which is what the site's archive template is set to display if the tag page doesn't exist.

I tried creating a "tag-customposttype.php" template but this doesn't seem to be working at all.

I had a similar problem with creating the blog archives (as in, couldn't get the permalink structure to display properly, even after manually registering the post type in the theme's functions.php) and was able to solve it with the Archives for Custom Post Types plugin.

Unfortunately, this is site is running on localhost at the moment so I can't share the site itself, but I would love any help that you might be able to offer. I've spent hours searching the WP codex/forums/WP stackexchange/general internet for a solution and nothing has worked so far. Please let me know if there's any additional information that might be necessary - I've avoided pasting in any large blocks of code here because I think there may be quite a few areas where something could be going wrong. Thanks in advance!

1 Answer 1


/tag/thetag/ is the correct default permalink for a tag archive. There is no concept of per-post type taxonomy archives, just a single archive for all types.

The issue you have with a 404 on those pages if they only contain custom post types, is that the built in tag and category taxonomy archives by default only query the post post type. If you want to add custom types to that you need to hook pre_get_posts and add your custom types to those queries.

function wpd_custom_types_on_tag_archives( $query ){
    if( $query->is_tag() && $query->is_main_query() ){
        $query->set( 'post_type', array( 'post', 'your_custom_type' ) );
add_action( 'pre_get_posts', 'wpd_custom_types_on_tag_archives' );
  • 1
    Thank you! This did solve the issue and they are showing up now. An additional question, though, in relation to your initial statement: does this mean that it is not possible to show tag archives for only one custom post type? Feb 2, 2015 at 23:50
  • 1
    It's possible, but you'll have to add a rewrite rule for each tax/type combo to handle the incoming requests, and you'll have to filter the tag archive links to point to the correct archive.
    – Milo
    Feb 2, 2015 at 23:57
  • It didn't work for me until I added a lower priority parameter: add_action( 'pre_get_posts', 'wpd_custom_types_on_tag_archives', 11 ); Hope it helps someone! Oct 8, 2016 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.