1

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,

Ryanenter image description hereenter image description here

  • Change your field's return format to "Post Object" instead of "Post ID." That way you'll already have the post information in your get_sub_field() call and it will be in the order they selected. – WebElaine Dec 11 '19 at 19:08
2

I actually added these 2 lines and it worked

'post__in' => $instructors,
'orderby' => 'post__in',
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.