Mixed Events/Posts wp_query…
-
Hello,
I’m trying to return a list of events and posts together and I’ve hit a bit of a wall. Hoping some kind person can help me out.
I have a post category called novita (num 15) and an event category called novita (which, oddly also seems to be category id 15). However, I understand that events need to be queried using event_category rather than event ids. So…
I want to return where (post_type = ‘post’ and category = ’15’) or
(post_type = ‘event’ and ‘event_category’ = ‘novita’)So I’ve been playing around with boolean things in the args, but even without worrying about the category filter for a bit,
<?php $args = array( 'relation' => 'OR', array('post_type' => 'post'), array('post_type' => 'event')); $my_query = new WP_Query( $args ); // Returns just posts $my_query = new WP_Query( array( 'post_type' => array( 'post', 'event' ))); // Returns posts and events as expected
Any advice much appreciated.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Mixed Events/Posts wp_query…’ is closed to new replies.