Home Forums General Issues Order Post Objects by menu_order Reply To: Order Post Objects by menu_order

  • 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
    if( $post_objects ): ?>
        <?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <?php endforeach; ?>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>