5

here's another stumper.

I have a tag.php page. It works fine, unless you click a tag that is in a post associated with a custom post type. Then it doesn't work. Its like that tag, doesn't exist. But its just a tag that's used cross site.

I'm not too sure why? And the codex isn't helping much after a lot of searching.

anyone ever run into this issue? I'm stumped.

thanks.

Nadine

12

If this is related to your other question, what you've got is a custom taxonomy, so you need either a taxonomy-{taxonomy}.php template (in your case taxonomy-article_topics.php), or just a more general taxonomy.php template.

(also, go back and accept answers to your other questions here if they've been solved!)

UPDATE

sorry, misunderstood your question-

add this to your functions.php template file to show your custom post types on tag pages:

function wpse28145_add_custom_types( $query ) {
    if( is_tag() && $query->is_main_query() ) {

        // this gets all post types:
        $post_types = get_post_types();

        // alternately, you can add just specific post types using this line instead of the above:
        // $post_types = array( 'post', 'your_custom_type' );

        $query->set( 'post_type', $post_types );
    }
}
add_filter( 'pre_get_posts', 'wpse28145_add_custom_types' );
  • I already have a taxonomy.php template, it serves as an archive for the article_topics. But the tags I'm using are site-wide already existing tags. So that's why I am confused...because this for example: <?php single_tag_title( ); ?> ...works fine, it just won't display any posts. (ok, re: accept answers...sorry). – Nadine Sep 10 '11 at 4:22
  • @Nadine - see edit above. – Milo Sep 10 '11 at 5:14
  • Note that using this code results in no navigation on the tag page (WP 3.9.1). – MiniRagnarok Jul 18 '14 at 17:46
  • Here is a refinement of this answer that accounts for the navigation. Search for 'Designophobia'. The person underneath them also suggests a less intrusive addition. wordpress.org/support/topic/… – MiniRagnarok Jul 18 '14 at 18:00
  • @MiniRagnarok - just add a check for $query->is_main_query() to the above to exclude all queries except the main query. – Milo Jul 18 '14 at 18:46

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