You can use this filter to change order :
$type = "cptCode";
add_filter("rest_" . $type . "_query", function ($args, $query) {
$args["orderby"] = "meta_value";
$args["meta_key"] = "my_meta_field";
return $args;
}, 10, 2);
You can also test $_GET
to change the order conditionally.
Related Posts:
- Update CPT meta data using REST API
- Getting meta in editor plugin, and event triggering issue
- post meta parameter in post custom-post-type endpoint with restapi
- WP API Response does not show my registered metadata
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Saving custom post types post_meta over REST-API fails
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- Ordering posts having multiple post-meta date fields
- WP Rest API Querying Custom Posts by ACF fields
- Grossly inefficient wordpress loops!
- How to get dynamically custom post type that are under a certain category
- Get the Category Name instead of ID from WP-API
- How Do I Use WP_Query to Run This Database Query as Search Result?
- bulk Update post_meta with default values
- Get custom post type REST API not working
- Custom post type category not displaying in custom post type
- How to make custom post meta wp_editor translatable?
- How to add multiple featured image in meta box in post editor?
- update_post_meta() whenever custom post type is updated
- Custom search with Custom Fields in WP REST API?
- How to best delete orphan wp_postmeta
- How can I get_post_meta() in the most efficient way?
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- WordPress Orderby Numeric Value Not Working
- Replace title column in post list with post meta value
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- List all images from a single post meta value
- Add custom parameter to REST API request of a custom post type?
- Custom Taxonomy Invalid in REST API
- Ordering posts in Search & taxonomy by post_meta
- how to delete all users and posts based on ‘user_meta’?
- Meta Key Value in current-user-only loop
- How to implement a Google map store locator
- Cannot add custom field to “orderby” parameter in Rest API
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Restrict Access to Posts based on Custom User and Post Meta Data
- Expose a custom field of a custom post type to the REST API
- Custom post type archive page – Posts overview – with one modal for multiple posts?
- get_post_meta returning no value in custom post type alert email
- WP Rest API – How to get an empty response if query has no posts
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- Show future events based on custom field AND order by date
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Create custom post with meta field with AJAX and the WordPress REST API
- create custom meta box with default value
- Issue on Working with Metabox – Checkbox to enable Sale Items
- delete_post_meta() for whole CPT / multiple posts?
- How to move a post to different post type with all meta data?
- Why do I have to press the “Update” button twice to save my meta box values?
- How to see posts in taxonomy endpoint
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- REST filters only firing when I have a param set
- Custom Post Type API doesn’t show taxonomy or category array
- Problem with adding custom post type meta to header by plugin
- How to call a post’s metadata in shortcode.php?
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- Get all metadata for a given custom post type
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Advanced custom field – posted fields from custom post type
- updating one custom meta field only
- Add a class to post_class if more than one post shares same meta_value_num
- Add a meta field to the list of results for a custom post type
- How can I create new CustomPostType record using wp.api.collections?
- Custom endpoint filtering post by custom taxonomies
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- wp rest api orderby field in a custom table
- Add a form in every post and save data in post meta
- URL issue retrieving Custom Post Types using Backbone JS API
- Show posts from WP Custom Post Type selected from a field in a metabox
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Peepso: Add extra data field (custom post meta) to postbox
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to get post detail based on URL of the post
- Stripe multiple transactions
- How to get Current week and current date record wp query
- Edit is changing my custom’s post type parent id
- How to add post reference field to a plugin?
- WordPress custom post type
- Edit post meta direct from post.php?
- Custom Post Type meta oembed html output resulting in WSoD
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Change the contents of a dropdown through the admin panel?
- fetch meta fields inside a widget
- Custom post type – update_meta not working
- Use a Variable in update_post_meta as the $meta_key
- Create settings page to enable or disable CPT
- Get all posts of any post type in a category from REST API
- Changing to different post type maintains the redirection?
- How do I add the “orange counter” next to a Custom Post Type?