How to get post revisions in my custom rest API? [closed]
From just looking at your snippet you’re not actually setting $post_revisions to any value before assigning it to your $post_data array
From just looking at your snippet you’re not actually setting $post_revisions to any value before assigning it to your $post_data array
Actually, when you set author_name, WP_Query will use get_user_by( ‘slug’, <author name> ) to find a user with the specified “nice name” (user_nicename) value, and if found, then WP_Query sets the author arg to the found user’s ID. Therefore you can follow the same approach, but you would use get_users() to find users having the … Read more
You could hook into the login process in the WP site and create a unique token (stored in meta) for that user on login. The token can then be sent to the other server, that could query the WP API with that token. You would have to create a custom endpoint that validates the user … Read more
From your comments: I just wanted to find out if there was a core endpoint for listing custom taxonomies with associated post type records. And as I said in my original answer: (slightly modified, though) The endpoint in question is a taxonomy term endpoint which returns the data (e.g. description, name and slug) for a … Read more
You don’t. That’s not how block attributes work, and it’s not what they’re for. A blocks attributes belong to that block, and are used by the editor to generate that blocks HTML, but once they’re saved in the database, they’re just HTML. There’s no block table, no mapping/index of block attributes in the database, post … Read more
it just seems to be ignoring only the custom parameters I have defined in my functions file There are two issues in your code: WP_REST_Request::set_query_params() actually accepts just one parameter, which is an array of arguments, so your code should look like so: $request->set_query_params([ // pass a single array containing one or more arguments ‘per_page’ … Read more
WP REST API depends on WordPress, as it is just another interface for interacting with its other APIs. If BackPress (https://backpress.org/) was still in development, you could have had some chance with it, but it seems the project is abandoned. The plugin that was merged with WordPress Core is available here: https://github.com/WP-API/WP-API but is also … Read more
I solved the issue thanks to this answer: Serialized settings in rest api. I was able to store all the options as a json object: /** * Create plugin options schema as an object and prepare it for the rest api. * WP >=5.3 */ function my_register_settings() { $general_options = [ ‘show_in_rest’ => [ ‘schema’ … Read more
You could use transients: function requestApi() { $cache_key = ‘your_transient_name’; $values = get_transient( $cache_key ); // if no data in the cache if ( $values === false ) { // build the URL for wp_remote_get() function $arguments = [ ‘method’ => ‘GET’, ]; $request = wp_remote_get( ‘https://example.com.br/api/endpoint/product-id’, $arguments ); if ( !is_wp_error( $request ) && … Read more
When you register a route, parameters accepted via the query string (eg. ?a=b&c=d) are not registered as part of the endpoint, like you have done. Those parameters just need to be defined in the args property: add_action( ‘rest_api_init’, function() { register_rest_route( ‘woo/v2’, ‘woocommerce/order_summary_by_date’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘woocommerce_orders_by_dates’ ‘args’ => array( ‘start_date’ => … Read more