Title: Mixed Events/Posts wp_query&#8230;
Last modified: August 21, 2016

---

# Mixed Events/Posts wp_query…

 *  [jeremy2805](https://wordpress.org/support/users/jeremy2805/)
 * (@jeremy2805)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-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.
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878399)
 * here’s another thread which may help you with this –
 * [http://wordpress.org/support/topic/custom-query-ignores-scopefuture?replies=10](http://wordpress.org/support/topic/custom-query-ignores-scopefuture?replies=10)
   
   [http://wordpress.org/support/topic/category-from-wp_query?replies=9](http://wordpress.org/support/topic/category-from-wp_query?replies=9)
 *  Thread Starter [jeremy2805](https://wordpress.org/support/users/jeremy2805/)
 * (@jeremy2805)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878466)
 * Thanks but I can’t see what you’re suggesting that I try. My problem is that 
   maybe I’m doing to ‘relation’ => boolean thing wrong and those two threads (and
   the threads pointed to from them) are about dates.
 * Sorry to be a pain, but could you elaborate?
 * Thanks.
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878477)
 * I’m not sure I follow what you’re trying to do. Do you want to list all posts
   in category 15 with all events in event category 15?
 *  Thread Starter [jeremy2805](https://wordpress.org/support/users/jeremy2805/)
 * (@jeremy2805)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878478)
 * Yes, but I don’t think you can use category numbers for events (happy to be told
   differently) so it’s all posts where cat = ’15’ and all events where event-categories
   is ‘novita’ (the stub).
 * I’ve now got to the point where I can get them using separate wp_query’s but 
   not a merged result set (which I’m hoping to sort by post date.)
 * I’ve been trying to create a tax_query args array all afternoon. It’s doing my
   head in.
 *     ```
       <?php
   
       	$args = array(
       		'post_type' => array( 'event' ),
       		'event-categories' => 'novita',
       		'orderby' => 'date',
       		'order' => 'DESC',
       		'posts_per_page' => 12
       	); 
   
       	$my_query = new WP_Query( $args );
   
       	while ($my_query->have_posts()) : $my_query->the_post();
       ?>
       		<div>
       		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       		<div class="excerpt"><?php the_excerpt(); ?></div>
       	</div>
       	<?php endwhile;
   
       	$args = array(
       		'post_type' => array( 'post' ),
       		'cat' => '15',
       		'orderby' => 'date',
       		'order' => 'DESC',
       		'posts_per_page' => 12
       	);
   
       	$my_query = new WP_Query( $args );
   
       	while ($my_query->have_posts()) : $my_query->the_post();
       ?>
       		<div>
       		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       		<div class="excerpt"><?php the_excerpt(); ?></div>
       	</div>
       	<?php endwhile;
   
       ?>
       ```
   
 *  Thread Starter [jeremy2805](https://wordpress.org/support/users/jeremy2805/)
 * (@jeremy2805)
 * [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878480)
 * So with the meta_query disabled, the query returns all events and posts.
 * With the meta_query enabled, it returns nothing.
 *     ```
       <?php
   
       	$args = array(
       		'post_type' => array( 'event', 'post' ),
       		'orderby' => 'date',
       		'order' => 'DESC',
       		'posts_per_page' => 12
       /*		'meta_query'             => array(
       		  	'relation' => 'OR',
       			array(
       				'key'       => 'cat',
       				'value'     => '15',
       				'compare'   => '='
       			)
       			array(
       				'key'       => 'event-categories',
       				'value'     => 'novita',
       				'compare'   => '='
       			)
       		) */
       	); 
   
       	$my_query = new WP_Query( $args );
   
       	while ($my_query->have_posts()) : $my_query->the_post();
       ?>
       		<div>
       		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       		<div class="excerpt"><?php the_excerpt(); ?></div>
       	</div>
       	<?php endwhile;?>
       ```
   
 * I tried it with just the cat=15 bit in, and it returned nothing.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Mixed Events/Posts wp_query…’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [event-manager](https://wordpress.org/support/topic-tag/event-manager/)

 * 5 replies
 * 3 participants
 * Last reply from: [jeremy2805](https://wordpress.org/support/users/jeremy2805/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/mixed-eventsposts-wp_query/#post-4878480)
 * Status: not resolved