Tags archive page won’t show up for custom post types and takes you to a blank or 404 page

This is another bug within WordPress where it only looks for tags on posts and not the custom post types. Here is how to solve this problem.

If you are seeing the 404 page, chances are that you don’t have the tag.php file so go ahead and create tag.php if you don’t have one already.

Copy and paste the following code in your functions.php  file.

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if ( is_category() || is_tag() && empty( 
$query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
$post_type = $post_type;
$post_type = array('REPLACE WITH YOUR OWN ARRAY');
return $query;

Make sure to add your own array in the code. Example: ‘books, magazines, apps’

Comments ( 0 )

    Leave A Comment

    Your email address will not be published. Required fields are marked *