echo menu_order value in my theme

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

Solutions Collecting From Web of "echo menu_order value in my theme"

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;

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);