receive a custom parameter with rest api
receive a custom parameter with rest api
receive a custom parameter with rest api
I’ve found the problem, why it’s not working with the categories. I don’t know why, but when creating a post over the API, the post is published before the category is correctly set. Now, I’m creating drafts (already with correct category). With a second PUT-Request I set the status to “publish” and publish my posts. … Read more
WP-REST create user with custom meta
Currently there is not a way to do this via the core API, though this could change in the future. To retrieve this form of content you have to create a new endpoint.
You can modify the arguments of the post type to enable the REST API: function wpd_tribe_events_args( $args, $post_type ) { if ( ‘tribe_events’ == $post_type ) { $args[‘show_in_rest’] = true; } return $args; } add_filter( ‘register_post_type_args’, ‘wpd_tribe_events_args’, 20, 2 );
To access posts via meta key you need to hook into the [rest_query_vary filter].1 The example I was thinking of when I read your question is the same one found on the post @WebElaine commented. I’ve merely added it below: function my_allow_meta_query( $valid_vars ) { $valid_vars = array_merge( $valid_vars, array( ‘meta_key’, ‘meta_value’ ) ); return … Read more
Uninstalling and reinstalling all plugins revealed the answer, which I recommend as the first step for addressing this sort of problem. The problem was apparently due to a conflict between WC-Vendors and another plugin which declared the same class WC_Email_Notify_Shipped. So I disabled WC-Vendors, which we weren’t using at the time.
REST API authentication for a plugin
The answer was that I was not referencing the 0 index of the json post-meta-fields array. It was trying to return an array instead of just the string. Instead of ‘color’ => $article_array[‘post-meta-fields’][‘color’] I needed ‘color’ => $article_array[‘post-meta-fields’][‘color’][0]
You can turn your AJAX requests into a REST endpoint to get rid of this common 0 response. All you have to register 2 REST routes for your requests: add_action( ‘rest_api_init’, function () { //Path to approve comment register_rest_route( ‘john_doe/v2’, ‘/approve_comment/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘approve_my_comment’ ) ); // Path to delete comment … Read more