I have two pieces of code and they're working well on their own. All I need is to put these two conditions into one query.
The first one:
Code: Select all
<?php
function childtheme_cat_limited_blog( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'events_categories', 'mycategory1' );
}
}
add_action( 'pre_get_posts', 'childtheme_cat_limited_blog' );
?>Code: Select all
<?php
function childtheme_cat_limited_blog( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'category_name', 'mycategory2' );
}
}
add_action( 'pre_get_posts', 'childtheme_cat_limited_blog' );
?>Thank you!
(My goal is here to display posts from two categories on a homepage of a Wordpress site, but to complicate things the two categories are from two different post types.)