Instead of query_posts
try using WP_Query
class. http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
This is example from codex:
$args = array(
'post_type' => 'my_custom_post_type',
'meta_key' => 'age',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'age',
'value' => array( 3, 4 ),
'compare' => 'IN',
),
),
);
$query = new WP_Query( $args );
Related Posts:
- Posts sortable column not sorting properly for custom field numbers
- How to update custom fields using the wp_insert_post() function?
- Most efficient way to add javascript file to specific post and/or pages?
- Display all values of custom a field created with ACF on a page
- Adding custom input for data attribute in insert media modal
- How to automatically apply woocommerce product title to all product images alt tags?
- Display sorting options dropdown when using WooCommerce product category shortcode
- How to handle a custom form in wordpress to submit to another page?
- If Custom Field is empty don’t display div
- wp_get_nav_menu_items() with ACF
- Save custom field on WP_List_Table
- Sum All the Post Meta of Published posts of Current Logged in user
- How do I get the value of a current user’s custom field?
- Trying to retrieve meta values from three different meta keys and display in rows
- WP post meta – for loop inside for loop
- custom fields anchor points php
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- When working with a post, almost all wp_postmeta are deleted
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- What syntax is this? “{{post.price}}”
- Updating Lat and Lng of posts automatically gives sporadic results
- How to display custom field from a gallery thumbnail?
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- Getting a value from a custom field from a page that shares a parent with the current page
- meta field for numerous links
- Array sorting assistance
- Custom fields changes the formatting of metabox input
- Include a custom field in mysql query
- Display Content Based on Custom Field Value
- php if, else & custom fields – syntax error
- How to get the first letter from custom field?
- Meta box not saving spaces
- divide custom field values in div every two values
- custom field meta-box with dropdown/autocomplete
- Showing custom field contents without listing description
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- How to exclude post from being queried based on custom meta value
- Query category-specific, paginated posts and allow viewer to change sort order
- Sort posts by title, sort array by largest number [duplicate]
- If custom field doesn’t exist, or exists and it’s true show title?
- How to link a word comprised of a custom field with another?
- Custom field in title
- If Elseif Query
- How can I put a custom field as the link of a button shortcode?
- WordPress – show all posts + ones with specific tag
- Outputting a custom field in PHP
- Sorting Meta Fields?
- Custom fields randomly stop working
- Display selected parts from selected pages on the frontpage?
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- ISOTOPE – Missing/Invalid Arguement Get Terms
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- PHP Puzzle: Unique Styles with PHP loop
- I want Page titles and excerpts to show up on home.php in certain order
- category & sub category order issues in wordpress
- Search result page – display values from the result’s metaboxes
- Display custom meta box in my template file
- Query posts by custom fields (object post)
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Metadata on the WP_Post object
- Sort author list alphabetically
- Appending an ACF custom field to the page title
- Too many if’s and else if’s ?? – Must be better way [closed]
- Advanced Custom Fields Show PHP in Text Areas
- WP query with variables gives no result for specific user
- Grabbing value of input field inside of array
- Displaying custom meta box value in a custom post page
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Convert custom field date format to “WordPress default”
- I want to show image from custom field image on my custom page template
- How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress
- How do I organize posts based on their taxonomy?
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- What is wrong with my sorting logic?
- Shortcode Displays 2 times
- How to execute a shortcode within a custom field?
- ACF number less than comparison not working
- fetch from an external api call and display results in page
- Problem with custom user fields default value and retrieval
- Cannot Access ACF Field Values via my Plugin
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- How to create advanced custom fields for backend content
- ACF block gutenberg aligncenter don’t work
- How to pull through page title depending on which radio button is selected on the specific page?
- Display WooCommerce Order Custom Field In Template (HPOS)
- How can I display a layout differently depending on whether the user is on Mobile or PC?
- hide “Open in New Tab” checkbox in link field
- Want to add custom post type for facebook feed
- Exclude function for custom pages, exclude custom ACF fields
- Custom rest fields not loaded in rest api cpt response
- Display posts in correct month order using single date custom field