Aleš Sýkora wrote

Show All post types in category archive with/without oxygen

28. 10. 2020 in ,

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.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Change WP Rocket lazyload treshold
21. 1. 2021 in
Default treshold for lazyload is 300px in WP-Rocket. That means that images that are within 300px of the viewport (browser window) are loaded for smooth user experience. If you like to load less images – for example 100px after viewport only – you can not set it up directly in WP Rocket’s settings page. To […]
Read More
Aleš Sýkora wrote
Featured Image missing after WordPress update
22. 3. 2021 in
Using WordPress + Oxygen builder and can not found featured image in post/page settings? It happend to me after WordPress 5.7 update. If you didn’t disabled it in gutenberg settings, then you might have same problem as me. How to fix it? Install/re-Install theTwenty Twenty-One theme to your website and your featured images will be […]
Read More
Aleš Sýkora wrote
Get a grandparent post ID from a shortcode
1. 7. 2019 in
This simple shortcode will allow you to get that grandparent post ID without the need for additional Content Templates or Views.
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram