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.
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?
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;
?>
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.