I am creating a website for a theatre company, and I am creating an index of all past, current, and future productions. I would like the index to 'orderby' the ending date of each production (ACF 'date' field type; 'ending_date').
Here is an example of my query:
<?php
$futureProd = array(
'post_type' => 'productions',
'posts_per_page' => -1,
'meta_key' => 'ending_date',
'orderby' => 'meta_value',
'order' => 'ASC',
);
$slider_posts = new WP_Query($futureProd);
$array_rev = array_reverse($slider_posts->posts);
$slider_posts->posts = $array_rev;
?>
Have also tried the following, adding the 'meta_value_date' as well as 'meta_value_num' alternatives:
<?php // query posts
$futureProd = array(
'post_type' => 'productions',
'posts_per_page' => -1,
'meta_key' => 'ending_date',
'orderby' => 'meta_value_date',
'order' => 'ASC',
);
?>
AND
<?php // query posts
$futureProd = array(
'post_type' => 'productions',
'posts_per_page' => -1,
'meta_key' => 'ending_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);
?>
No matter what I try, the posts refuse to order themselevs by the meta_value, and instead opt to order themselves by the default, post date.
I'm sure I'm missing something simple.
Anyone have any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…