Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work its way up "3","4","5" each time adding 1 to the value in the loop. Here is my current code which obviously just queries for the value "2" where do I add an increment in this function?

?php 

// args
$args = array(
    'posts_per_page'   = 4,
    'post_type' = 'post',
    'meta_key' = 'meta-select',
    'meta_value' = '2'
);

// get results
$feature_query = new WP_Query( $args );

// The Loop
?
?php if( $feature_query-have_posts() ): ?
    ul
    ?php while ( $feature_query-have_posts() ) : $feature_query-the_post(); ?
        li
            a href="?php the_permalink(); ?"?php the_title(); ?/a
        /li
    ?php endwhile; ?
    /ul
?php endif; ?

?php wp_reset_query();?

Topic loop post-meta wp-query query-posts query Wordpress

Category Web


Not tested but you can try this:

$args = array(
    'posts_per_page'   => 4,
    'post_type'        => 'post',
    'meta_key'         => 'meta-select',    
    'order'            => 'ASC',
    'orderby'          => 'meta_value_num',
    'meta_query' => array(
        array(
          'key'     => 'meta-select',
          'value'   => array( 2, 3, 4, 5 ),
          'compare' => 'IN',
        ),
      ),
);

Ordering is done by value of meta field meta-select in ascending order. Also in meta_query, meta value is checked in the array of possible values

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.