As with many things, there is more than one way to accomplish this. A simple method is to pass an order
and orderby
value to the query. I believe the most efficient way to do this sort on a specific page is with pre_get_posts
but rather than over-complicate this for you, the simple method instead.
You’ll create an “arguments” variable and pass these to a custom query. You’re code would then look like this:
<?php
// These are the arguments for the custom query
$args = array(
'orderby' => 'menu_order',
'order' => 'ASC'
);
// Instantiate query
$query = new WP_Query($args);
if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<img src="https://wordpress.stackexchange.com/questions/198375/<?php the_field("picture'); ?>" class="img" width="467" height="395" />
<h2><?php the_field('name'); ?></h2>
<?php
the_field('description');
endwhile;
endif;
?>
This will sort your based on the menu order. There are many other options for sorting available. See the Codex entry for WP_Query class:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
EDIT – Meta query option based on info from OP. $args
variable now contains orderby
and meta_key
values.
<?php
// These are the arguments for the custom query
$args = array(
'orderby' => 'meta_value_num',
'meta_key' => 'order'
);
// Instantiate query
$query = new WP_Query($args);
if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<img src="https://wordpress.stackexchange.com/questions/198375/<?php the_field("picture'); ?>" class="img" width="467" height="395" />
<h2><?php the_field('name'); ?></h2>
<?php
the_field('description');
endwhile;
endif;
?>