tag.php doesn't work with tags on a custom post type post?

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.



Solutions Collecting From Web of "tag.php doesn't work with tags on a custom post type post?"

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!)


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' );