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

Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API

I ended up extending the API like suggested in the comments to my question, although I was hoping there was a default route that fetched all posts of all post types. Apparently, there isn’t. So here’s my solution: add_action( ‘rest_api_init’, ‘custom_api_get_all_posts’ ); function custom_api_get_all_posts() { register_rest_route( ‘custom/v1’, ‘/all-posts’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘custom_api_get_all_posts_callback’ … Read more

WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?

Sorry for answering my own question but it may help some other devs too. I created this additional filter ‘json_query_var-meta_query’that returns the necessary arguments. function adjustQrry($data){ $args = array(); $args[‘relation’] = ‘AND’; foreach ($data as $key=>$value) { if ( ‘relation’ === $key ) { $args[‘relation’] = $data[‘relation’]; } if ( substr($key, 0, 3) === ‘key’ … Read more

Using Backbone with the WordPress AJAX API

You need to override the Backbone.sync function to change the URL used for the AJAX call. You can learn from the plugin wp-backbone does this and more. Below you can see from it how it changes all the actions into either POST or GET, create the parameters, add the action parameter and more. (function($) { … Read more

Getting user meta data from WP REST API

Look into register_rest_field() to register meta with the rest api. add_action( ‘rest_api_init’, ‘adding_user_meta_rest’ ); function adding_user_meta_rest() { register_rest_field( ‘user’, ‘collapsed_widgets’, array( ‘get_callback’ => ‘user_meta_callback’, ‘update_callback’ => null, ‘schema’ => null, ) ); } And then put your get_user_meta bit in the callback. function user_meta_callback( $user, $field_name, $request) { return get_user_meta( $user[ ‘id’ ], $field_name, true … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş