October 31, 2018
I usually use a counter to show show items in a list, but I was recently working with numbered Modules, and needed specific values associated with each Page / Post, so instead I found myself using menu_order.
Here you can get the value of the menu_order field to show on a single Page or Post:
global $post; $menu_order = $post->menu_order;
Within the loop:
foreach($modules as $post) : setup_postdata($post); ?> <div class="module"> <span><?php echo $post->menu_order; ?></span> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </div> <?php endforeach; wp_reset_postdata(); ?>