Wonder why your WordPress theme is not recognizing your custom post types on category archive pages? Archives.php displays ‘posts’ data by default, but you can add the following tweak to your functions.php file to alter the archives.php to display all or a selection of your custom posts.
Make sure if you want to add more than one custom post type, to separate them with commas.
1 2 3 4 5 6 7 8 9 |
function digimix_add_custom_types( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'post_type', array( 'post', 'insert-your-custom-post-type-here' )); return $query; } } add_filter( 'pre_get_posts', 'digimix_add_custom_types' ); |