I have to order items from wp_post by their menu_order (pages only).
I’ve written this line:
$query = new WP_Query();
$all = $query -> query(array('post_type' => 'page', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'DESC'));
$children = get_page_children($id, $all);
foreach ($children as $child) {
if ($child -> ID == get_the_id()) {
echo '<li class="active"><a href="' . get_permalink($child -> ID) . '">' . $id . $child -> post_title . '</a></li>';
I see the items but they are not ordered.
Thanks.
FZ
I would say that the issue relates to the fact you are passing the
$allobject throughget_page_childrenbefore using it in a loop.Why don’t you just forget get_page_children and add ‘post_parent’ to your list of WP_Query arguments?
A helpful thread on WordPress Stack Exchange;
https://wordpress.stackexchange.com/questions/35123/wp-get-all-the-sub-pages-of-the-parent-using-wp-query
EDIT.
To expand on comments. Sometimes there’s confusion about menu_order – it does not relate to wp_nav_menus but to the Page Attributes Order input box, as shown below;