Merging two queries - a little help, please
Posted: Sat Nov 15, 2014 4:09 am
Now this must be easy enough, but I'm a noob so go easy on me, please
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:
And the second:
I'm sure it's a piece a cake for you guys, but I can't figure it out for the life of me, so any help would be greatly appreciated!
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.)
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.)