I created a Post Object field type (see attached screenshot post-object-0.png)
How do I output the instructors in order by the selection choices made by the users (see attached screenshot post-object.png)
My query is as follow:
$instructors = get_sub_field( 'instructors');
//var_dump( $instructors );
$total = count($instructors);
$posts = get_posts(array(
'post_type' => 'kgi_personnel',
'posts_per_page' => $total,
'post_status' => 'publish',
'include' => $instructors
));
Thank you in advance,
Ryan
I created a Post Object field type (see attached screenshot post-object-0.png)
How do I output the instructors in order by the selection choices made by the users (see attached screenshot post-object.png)
My query is as follow:
$instructors = get_sub_field( 'instructors');
//var_dump( $instructors );
$total = count($instructors);
$posts = get_posts(array(
'post_type' => 'kgi_personnel',
'posts_per_page' => $total,
'post_status' => 'publish',
'include' => $instructors
));
Thank you in advance,
Ryan
Share Improve this question asked Dec 11, 2019 at 18:58 user3298611user3298611 535 bronze badges 1 |1 Answer
Reset to default 3I actually added these 2 lines and it worked
'post__in' => $instructors,
'orderby' => 'post__in',
get_sub_field()
call and it will be in the order they selected. – WebElaine Commented Dec 11, 2019 at 19:08