Hi there,
Have spent hours reading, researching and trying… please help.
eg.
( ‘orderby’ with multiple ‘meta_key’s If you wish to order by two different pieces of postmeta (for example, City first and State second), you need to combine and link your meta query to your orderby array using ‘named meta queries’.)
The data selection part works, but the sorting of the output in the looper is not working.
- Have installed code snippet to allow for PHP to generate Shortcode,
- Created Page to house the shortcode, to generate the Query String, and copy it into the the Posts Looper provider (type Query String) to check the output.
// Custom Post Type: navigate-activity
// Phase: acf_activity_phase
// Step Number: acf_phase_step_nbr
// Task Number acf_phase_step_task_nbr
// Activity Number acf_step_task_activity_nbr
Want to Loop over specified Phase, Steps, Tasks
and have navigate-activity posts output sorted by
acf_activity_phase, acf_phase_step_nbr (within phase), acf_phase_step_task_nbr (within the Step), acf_step_task_activity_nbr (within Task)
The PHP code is…
$meta_query[] = array(
‘relation’ => ‘AND’,
‘phase’ => array(
‘key’ => ‘acf_activity_phase’,
‘value’ => ‘Discover’
),
‘step’ => array(
‘key’ => ‘acf_phase_step_nbr’,
‘value’ => array(1,2,3,4),
‘type’ => ‘numeric’
),
‘task’ => array(
‘key’ => ‘acf_phase_step_task_nbr’,
‘value’ => array(1,2,3,4),
‘type’ => ‘numeric’
),
‘orderby’ => array(
‘phase’ => ‘ASC’,
‘step’ => ‘ASC’,
‘task’ => ‘ASC’
)
);
$query = array(
‘post_type’ => ‘navigate-activity’,
‘post_status’ => ‘publish’,
‘numberposts’ => -1,
‘offset’ => ‘0’,
‘no_found_rows’ => true,
‘meta_query’ => $meta_query
);
echo( http_build_query( $query ) );
Query String =
post_type=navigate-activity&post_status=publish&numberposts=-1&offset=0&no_found_rows=1&meta_query%5B0%5D%5Brelation%5D=AND&meta_query%5B0%5D%5Bphase%5D%5Bkey%5D=acf_activity_phase&meta_query%5B0%5D%5Bphase%5D%5Bvalue%5D=Discover&meta_query%5B0%5D%5Bstep%5D%5Bkey%5D=acf_phase_step_nbr&meta_query%5B0%5D%5Bstep%5D%5Bvalue%5D%5B0%5D=1&meta_query%5B0%5D%5Bstep%5D%5Bvalue%5D%5B1%5D=2&meta_query%5B0%5D%5Bstep%5D%5Bvalue%5D%5B2%5D=3&meta_query%5B0%5D%5Bstep%5D%5Bvalue%5D%5B3%5D=4&meta_query%5B0%5D%5Bstep%5D%5Btype%5D=numeric&meta_query%5B0%5D%5Btask%5D%5Bkey%5D=acf_phase_step_task_nbr&meta_query%5B0%5D%5Btask%5D%5Bvalue%5D%5B0%5D=1&meta_query%5B0%5D%5Btask%5D%5Bvalue%5D%5B1%5D=2&meta_query%5B0%5D%5Btask%5D%5Bvalue%5D%5B2%5D=3&meta_query%5B0%5D%5Btask%5D%5Bvalue%5D%5B3%5D=4&meta_query%5B0%5D%5Btask%5D%5Btype%5D=numeric&meta_query%5B0%5D%5Borderby%5D%5Bphase%5D=ASC&meta_query%5B0%5D%5Borderby%5D%5Bstep%5D=ASC&meta_query%5B0%5D%5Borderby%5D%5Btask%5D=ASC
As you can see the results are NOT ordered by:
acf_activity_phase, then acf_phase_step_nbr, then acf_phase_step_task_nbr
Please please help… what am I doing wrong?
Private note with login provided.
Thanks in Advance
Simon