I did not use the Post Types Order, but put the function from kakaroto84 in my functions.php.
Now my code looks like this:
<?php
$child_pages = get_field('child_pages');
objectRSort($child_pages, 'menu_order');
if( $child_pages ): ?>
<ul class="subpages">
<?php foreach( $child_pages as $post): ?>
<?php setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Thank you kakaroto84!
Yes, you’re right. The only difference is I want it sorted by menu_order. Do you know how I can do that?
I can get the posts I want using the code below, but then how do I sort them by menu_order?
<?php $post_objects = get_field('child_pages'); // from http://www.advancedcustomfields.com/resources/field-types/post-object/
if( $post_objects ): ?>
<ul>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
Thanks!