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
Related Posts:
- WP_Query vs get_posts
- Include current post into loop
- Should I reset $wp_query?
- I need query_posts() to order results first by a meta value and then by post ID
- Ordering Posts by parent category, name ascending
- How to query post ids liked by the Author
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- Some doubts about how the main query and the custom query works in this custom theme?
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- WP_Query: query posts by ids from array?
- What is the most efficient way of querying posts based on visits and date for current day?
- pre_get_posts with get_posts
- WordPress Custom Query to show posts from last x years
- Get posts by meta data OR title
- Identify which loop you are hooking into; primary or secondary?
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- How to query ‘posts_per_page’ to display a different blog posts index template?
- meta_query on a date range using an array of values
- Pass the same object to multiple widgets in a template with one query
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- How to Loop within a Loop (Display Children and then Grandchildren)
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- 2 loops on page – one with orderby rand second orderby date
- Undefined WP_Query::has_posts()?
- Query post with meta_query where date is not in future
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- if/else on custom query gives 200 OK when condition not met?
- Pull post meta with post_query?
- Query posts by specific word on title
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Five posts from a category in footer
- Change query_posts to WP_Query in page but does not work
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- Custom Query num_rows returns wrong amount
- Fetch Record based on meta key dates
- Slow page loads due to WordPress Core Query
- how to make members list directory through wordpress post custom meta key.
- Order by empty custom field
- Check if loop has any categories?
- How to get list of posts from permalinks?
- New WP_Query loop in admin causes problems
- Is_single() conditional tag returns null in query
- How do I rewrite this loop as a new WP_Query style-loop?
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- WordPress query posts with multiple post_meta data
- How to provide meta_key array to wp_query?
- How to create custom query by keyword in post title?
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- How to filter query loop block with a search string from the query parameters
- Filtering by multiple conditions in the loop
- 2 queries with counters
- I am officially missing something about transient posts
- Why doesn’t my WP Meta Query return any results?
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- WP_Query meta compare must include ALL array values
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Filter products on category AND tag
- How do i create a custom post query when the meta value is an array?
- Duplice post with standard WP loop – fixed by using query_posts() instead
- pre_user_query vs pre_get_posts
- How do I stop the same post showing multiple times in a archive?
- Query against multiple locations within single custom post type post
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WP_Query & Duplicate entries
- update_post_meta() not updating
- How to show post title in content editor in backend?
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- how to show more than 1 post into three columns query
- WP_Query with child element
- WP_Query secondary query failing
- Loop through multiple custom fields with increasing number
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- How to organize a WP_Query’s list of posts by category and display category title?
- When should you use WP_Query vs query_posts() vs get_posts()?
- Converting an existing query_posts to WP_Query
- loop through custom post types with meta data
- WordPress Query showing multiple titles
- custom query to get posts
- query by meta value then date and not empty meta value
- Multiple loop for “featured” items returns wrong posts
- Query posts by meta value and sort by another meta key
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Show number of posts AND number on current page (cannot make it work)
- How to get posts that have certain meta key value and order based on another meta key’s value