You have to add:
'meta_key' => 'key_name'
to the arguments array in order to use the key with the orderby
parameter. Additionally you have to have the orderby
parameter like this:
'orderby' => 'meta_value'
But if you have the data you want to sort by saved into an array, like your code suggests, you have a problem. You won’t be able to use it for sorting, take a look at the answer to this question WP_Query meta_query by array key for an explanation.
Related Posts:
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Control content before and after custom post type loop
- Get data from PHP to JavaScript to set position of each post on front page
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- How do I ensure that post_type and Taxonomy use the same slug?
- when looping through custom post data not appearing
- Combine multiple separate lists into one
- Adding a Section for Visitors
- Show parent category and subcategory once in while loop
- Custom taxonomy template for custom fields loop [closed]
- Add active class to foundation 6 tabs while looping categories
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- WordPress query posts by custom post type not workng
- Show Custom Post Type taxonomy term that matches custom field
- WordPress Custom Post Type and sort by Tags
- Looping taxonomy in taxonomy?
- How do I filter a custom post type loop by a field?
- I want to show image from custom field image on my custom page template
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- List terms from Custom Taxonomy
- Display custom post on home page based on a metabox selection
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- WP_Query search posts by custom post type and custom taxonomy
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Custom Posts Hierarchy? (State/City/Restaurant)
- Automatically populate a hierarchical taxonomy from a custom field
- Display custom field of specific post where post title matches variable
- Conditional to modify query results
- How to output wordpress custom tags separated by comma?
- Custom Post Type Loop within Shortcode
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Weird problem happening with custom taxonmy when creating/updating posts
- get_template_part for each level of taxonomy term
- Filter by custom taxonomy slug on a custom post type
- Normal pages as children of my Custom Post Type
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Only show posts from a certain category?
- Very Slow Page – How to Optimize # of Queries?
- Display CPT posts based on specific taxonomy
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- get_posts of Custom Post Type AND Custom Taxonomy
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- WP_Query orderby modified to include custom meta changes
- Custom Post Type Loop throws 500 error when used in widget
- Am unable to reset a query properly
- How to bulk copy custom fields between custom posts?
- get_attached_media() on author page not working
- Received nothing after executing AJAX post function
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- Retrieve value of a category’s custom field
- Calculate all custom field values in the post loop
- CPT + CMB2: data not displaying for only first post in loop
- Replace text in post from cvs
- Get next and previous 3 posts in a term in single post page
- wp_query check if integer exists in custom field’s array
- Get custom post type list for every category shortcode
- Loop custom taxonomy to get lists of cutom post types?
- How do i calculate the total of values of custom fields in custom post types?
- Custom loop with multiple taxonomy queries
- I would like to have different styles for my posts based on the content of each post
- search also in taxonomy, tags and custom fields
- Checking if Post Title is Unique as Loop Criteria
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Query & Order posts by custom fields
- Show a Category X’s custom post type on Category X archive page?
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Custom Tag Description unable to display just below and outside of the Loop
- Display all taxonomy terms, add class if term applies to current post
- Return the latest post from a custom Taxonomy and Post Type
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Show custom post type relationships by taxonomy
- get_post_meta not working on publishing
- Group CPT posts by custom taxonomy
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Using custom field content as expression in IF statement [closed]
- What’s the WP way to load remaining custom posts?
- Dynamic dropdown select values depending on other custom field value
- Categorize custom post type
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Hierarchy and access control for Custom Post Types (CPT)
- First custom field value (out of several) displayed twice after query
- Foreach loop returning more than one item when querying taxonomy
- Function to erase every post from a taxonomy
- Looping through custom taxonomy and display custom post types (Custom Post Type UI)
- Using page title as a link to term archive
- Displaying information from custom field on custom post type