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
- Display all posts in a custom post type, grouped by a custom taxonomy
- Creating Photo Gallery System with Custom Post Type
- How to solve suspected memory issue in custom WordPress loop?
- Automatically assign a custom post to a custom taxonomy based on custom field value
- Custom Taxonomy order by Custom Field
- Is there any performance consideration when using Custom Post Types?
- How loop through posts based on custom fields
- Show ACF field from custom taxonomy and display on the single template
- Get Custom Field Values by Another Custom Field in WordPress
- Conditional to modify query results
- Filter by custom taxonomy slug on a custom post type
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Am unable to reset a query properly
- 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?
- Retrieve value of a category’s custom field
- Get next and previous 3 posts in a term in single post page
- search also in taxonomy, tags and custom fields
- Return the latest post from a custom Taxonomy and Post Type
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Dynamic dropdown select values depending on other custom field value
- Full Custom Post Type List Organised by two Taxonomies
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Different options per post type in WP_Query
- Many to many to many custom post relationships
- Creating a non-hierarchical Taxonomy that behaves like categories
- Custom Post Type not showing in main loop
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Reusable metabox backend and frontend
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Let users upload image(s) to the post from front end
- Function to erase every post from a taxonomy
- Using page title as a link to term archive
- Custom Taxonomy dont save in a frontend form for post a custom post
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Should i use custom post type for a custom footer?
- Setup page template array in a custom post type
- What is the most efficient way to execute recursive complex queries?
- How to get post count of specific taxonomy that have store name & category
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Custom taxonomy terms as children of multiple custom post types
- CPT loop doesn’t seem to account for post date?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to display list of custom post taxonomy terms and their posts (if any)?
- Alike Shortcode using in Custom Shortcode
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Some posts not displaying by taxonomy term
- PHP Warning with Custom Fields
- posts_per_page is not working by term
- Filter Custom Post Type Posts by Taxonomy
- Change Search display for Custom Post Type
- Custom search for a custom post type in WordPress
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- tax_query not working?
- Show custom taxonomy not in submenu
- Can’t pick up a field created with Advanced Custom Fields
- Pods pagination erases my sub menu
- Loop with Custom Post Type and Taxonomies
- Function not pulling image or text from custom post type
- custom taxonomies are not showing up in get_taxonomies
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Sorting custom post types by taxonomy (So close)
- posting twice from an array?
- Custom Loop for custom post type. Compare by meta_value?
- Query Custom Post Type by Tag
- Custom Post type as Taxonomy
- Get custom post fields and display them
- How do loop categories post from according in WordPress? is it impossible to solve this problem?
- Create a WordPress loop that shows posts from a custom post type + filters the posts by taxonomies while hiding empty taxonomies
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template