Show All post types in category archive with/without oxygen

Author: Aleš Sýkora, 28. 10. 2020

If you want to display all post types posts - the custom and default, which use the same default category as a taxonomy, you need to put this in your custom code snippets plugin an change the array to your needed post types:

function custom_post_type_cat_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_category()) {
$query->set( 'post_type', array( 'post','recept', 'videa' ) );
}
}
}
add_action('pre_get_posts','custom_post_type_cat_filter');

Normally wordpress shows only the default posts in category archive.