Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

SDM36 on "WP Query date_query problem"

$
0
0

Hiya,

Basically I'm trying to order a bunch of posts by season; 'spring', 'summer' and what have you.

It occurred to me that the easiest way of achieving this was to run four new WP_Query's using date query for each season.

To that end I got this far:

<?php $args = array(
		'posts_per_page' => -1,
		'cat'	=> 19,
		'date_query' => array(
					array(
						'month' => 1,
						'month' => 2,
						'month' => 3
						 ),
				'relation' => 'OR'
				 )
			); 	?>
<?php $spring = new WP_Query($args); ?></p>
<p><?php while ( $spring->have_posts() ) : $spring->the_post(); ?>
<?php print_r($post); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

Yet that doesn't return anything.
It's definitely to do with the date_query array as when I remove it all posts come out fine.

I've followed the advice and format as per the codex and am left scratching the old head.

Anyone able to give me a quick pointer please?


Viewing all articles
Browse latest Browse all 8245

Trending Articles