Use a custom field named 'order'
in each post. Remove the field from posts you do not want to display. Then call the WP_Query object to sort the order field numerically (meta_value_num
) skipping any values less or equal to 0 (like in the meta_query
below).
$posts = new WP_Query( array(
'orderby' => 'meta_value_num',
'meta_key' => 'order',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'order',
'value' => 0,
'compare' => '>',
),
),
) );
if ( $posts->have_posts() ) {
echo '<ul>';
while ( $posts->have_posts() ) {
$posts->the_post();
printf( '<li><a href="https://wordpress.stackexchange.com/questions/118725/%s">%s (%s)</a></li>', get_permalink(), get_the_title(), get_post_meta( get_the_ID(), 'order', true ) );
}
echo '</ul>';
}
wp_reset_postdata();
In this example, the number in parenthesis in each link is the value in the 'order'
custom field.