[resolved] tag.php acting weird with custom post types (5 posts)

  1. nadine00
    Posted 4 years ago #


    I have a tag.php template, and currently it does not work when you click a tag with an article that is associated with a custom post type. I'm really confused, because its a site-wide tag....there's no upfront reason it shouldn't work.

    But the tag.php template just displays no article.

    The funny thing is that this: <?php single_tag_title( ); ?> ...works fine.

    Do I have to "get the current tag" and pass that into a custom query or something? Do I have to use an archive template instead? Am I just missing something really obvious that I can't find in the codex?

    I'm really new to custom post templates and so far, easy to set up: confusing to retrieve stuff from.

    So...help please? :(


  2. nadine00
    Posted 4 years ago #


  3. nadine00
    Posted 4 years ago #


    Basically what's going on is this:

    I go to Articles. Articles is a custom post type. In this custom post type I have allowed the user to use all the existing tags on the site.

    I click on a tag in a post that is posted in "Articles" it uses the tag.php template, but won't show posts with that tag. It will however show the tag title. So I don't really know what's going on.

    Wrong template to be using maybe?

  4. nadine00
    Posted 4 years ago #

    So apparently, this is a bug: http://core.trac.wordpress.org/ticket/14589

    And this, which I found over at stackexchange is a good fix.

    <?php function post_type_tags_fix($request) {
        if ( isset($request['tag']) && !isset($request['post_type']) )
        $request['post_type'] = 'any';
        return $request;
    add_filter('request', 'post_type_tags_fix');?>
  5. fireproofsocks
    Posted 4 years ago #

    WP's support for custom post-types is as varied and disorganized as its code. I noticed that posts show up in category and tag lists if you set the "has_archive" argument to true when you register your custom post-types via WP's register_post_type() function: http://codex.wordpress.org/Function_Reference/register_post_type

Topic Closed

This topic has been closed to new replies.

About this Topic