Hi,
I am trying to sort a wp_query based on a repeater sub_field_value.
Even though I found multiple instructions that seems related to that topic I can’t get it to work.
I have a repeater field ‘spieldaten’ (playtimes) with a date subfield ‘date’ (among ohter fields) on the regular post type. I am now trying to list all the playtimes ordered by date on a page.
$args = array(
'post_type' => 'post',
'post_per_page' => -1,
'meta_key' => 'spieldaten_0_date',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
// get results
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
while ( $the_query->have_posts() ) : $the_query->the_post();
while ( have_rows('spieldaten') ) : the_row();
if( get_sub_field('date') ) { the_sub_field('date'); }
/* other fields … */
endwhile;
endwhile;
endif;
What am I doing wrong?
Thanks a lot
L