Why is this query not working? (Standard posts + custom post type)

I’m trying to figure out why this query is not working, as it seems like it should be very straightforward. Basically, I’m querying for both standard posts of certain categories (and excluding another) and posts of the event custom post type after the current date. As it stands, I can only successfully query one or the other, i.e. posts by category or events after current date, but not both, together- what am I doing wrong here? Thanks for any direction.

$catslugs = array(‘home-slideshow’);
$catids = get_cats_by_slug($catslugs);

$args = array(
‘ignore_sticky_posts’ => true,
‘post_type’ => array(‘post’, ‘event’),
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘posts_per_page’ => 10,
‘category__not_in’ => $catids,
tax_query’ => array(
array(
‘taxonomy’ => ‘category’,
‘fields’ => ‘slug’,
‘terms’ => array(‘slug-1’, ‘slug-2’)
)
),
‘meta_query’ => array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘event_start_date’,
‘type’ => ‘DATE’,
‘value’ => current_time(‘Ymd’),
‘compare’ => ‘>=’,
),
)
);

(As the name suggests, the function above get_cats_by_slug simply returns category IDs by slug.)

Read more here:: Why is this query not working? (Standard posts + custom post type)

Leave a Reply

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