Aleš Sýkora / October 27, 2020 / 0 comments

Show All post types in category archive with/without oxygen

Post summary: 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: Normally wordpress shows only the default posts in category archive.

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.

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

0 comments

Share Your Thoughts