How to return Meta data from the REST API?

The first parameter passed to register_meta() is always post for posts, Pages (post type of page) and custom post types. However, the REST API Handbook says that: Prior WordPress 4.9.8, meta fields set to show_in_rest using register_meta are registered for all objects of a given type. If one custom post type shows a meta field, … Read more

Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)

To me, the simplest solution would be creating additional field in JSON response and populating it with selected post meta: function create_api_posts_meta_field() { // “tribe_venue” is your post type name, // “protected-fields” is a name for new JSON field register_rest_field( ‘tribe_venue’, ‘protected-fields’, [ ‘get_callback’ => ‘get_post_meta_for_api’, ‘schema’ => null, ] ); } add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ … Read more

How to filter custom posts by tags and custom fields?

you can use custom taxonomies and make you query_posts much easier! by that i mean create a custom taxonomy for type,duration like so: add_action(‘init’,’register_event_tax’); function register_event_tax(){ register_taxonomy(‘even_type’,array(‘events’), array( ‘hierarchical’ => false, ‘labels’ => ‘type’, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘type’ ), )); register_taxonomy(‘even_duration’,array(‘events’), array( ‘hierarchical’ => false, ‘labels’ => … Read more