Depending on what theme you’re using, it’s default functionality. Basically, the default category archive page only lists posts.
You’ll need to add this code to your functions.php file to take into account custom post types:
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if(is_category() || is_tag()) {
$post_type = get_query_var('post_type');
if($post_type) {
$post_type = $post_type;
} else {
$post_type = array('post','player'); // replace cpt to your custom post type
}
$query->set('post_type',$post_type);
}
return $query;
}
Replace player with your cpt name.
Thread Starter
nuonis
(@nuonis)
Thanks for the quick response! It’s good to know there is a fairly easy to fix for this, but the code you gave me isn’t working. I think there’s a conflict with the code that’s already in the functions.php file because when I insert your code, it makes my site go completely blank. I’m really not sure how to make this work on my own, so I’m also asking StudioPress to see if they can help.
Do you happen to have any insight on how I can insert the code without it breaking the site? If it helps, my functions.php file already has an “add_filter” code in there:
add_filter( 'comment_form_defaults', 'agency_remove_comment_form_allowed_tags' );
function agency_remove_comment_form_allowed_tags( $defaults ) {
$defaults['comment_notes_after'] = '';
return $defaults;
}
Not sure how to integrate your code in without creating a conflict…
I appreciate your help so much!!
Hi,
Just re-tested the code and it dose work as it should.
If you add it to the bottom of your functions.php, it really shouldn’t cause any problems or conflicts with other code. Also add_filter is just a generic function that allows you to modify things in the WordPress execution and isn’t the cause of the problem.
The only way I could help you if you edit wp-config.php, and turn on error repporting
define('WP_DEBUG', true);
Then you should get an actual error, not a blank page. Tell me what error you get and I’ll try to help you fix it.
Thread Starter
nuonis
(@nuonis)
Thank you so much for your time and help! It’s very much appreciated. It still won’t work for me. I’m sure I’m doing something wrong, but I can’t afford to spend more time trying to make it work so I will have to find another solution without the plugin.
Thanks again!
Sinoun