0

I thought this would be a simple task, but I cannot find anything on google.

I would simply like to echo the meun_order value in my loop.

I tried this but it's not in the post_meta table, its in the post's table.

<?php echo get_post_meta($post->ID, 'menu_order', true); ?>

Can anyone help please?

Thanks Josh

2

You can't use get_post_meta since the menu_order is stored in the posts table, like you said. But you can set up an easy database query to get the value.

$menu_o = $wpdb->get_var( "SELECT menu_order FROM $wpdb->posts WHERE ID=" . $post->ID  );
echo $menu_o;
1

I have answered similar question here:

Get current menu_order

get_post_field( 'menu_order', $post_id);

or try this inside the loop

get_post_field( 'menu_order', $post->ID);

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.