Widget – Store and update data

You probably want to look at using WordPress Transients as they can handle both the data and the timestamp/expiration. You can also check out The Deal with WordPress Transients by CSS Tricks which has some good info as well.

Most performant way of fetching remote API data?

The most performant way of fetching remote API data is not fetching it at all. Thus, use Transients API or WP Object Cache to save your computed results for future use and avoid calling external API (and further computations) on every subsequent request. Additionally, fetching, invalidating and regeneration of this data can be done in … Read more

WP Rest API not working

First you’ve to Check if the WordPress REST API is enabled or not The best way to check is to visit this URL: https://yoursite.com/wp-json. If you see some JSON response, REST API is enabled. If it’s showing some error page or returns to home page, REST API is not enabled. Then we’ve to enable it … Read more

Post body not working with wp_remote_post()

You’re setting the Content-Type header to application/json and wp_remote_post() doesn’t intelligently JSON-encode the request data (the body array), so you should manually do it. So for example: ‘body’ => json_encode( array( ‘Username’ => ‘myusername’, ‘Password’ => ‘mypassword’ ) )

Get all tags not just first 10 with wp api 2.0

If we look at the WP_REST_Controller::get_collection_params() method, we can see the minimum is 1 and the maximum is 100: ‘per_page’ => array( ‘description’ => __( ‘Maximum number of items to be returned in result set.’ ), ‘type’ => ‘integer’, ‘default’ => 10, ‘minimum’ => 1, ‘maximum’ => 100, ‘sanitize_callback’ => ‘absint’, ‘validate_callback’ => ‘rest_validate_request_arg’, ), … Read more

Creating woocommerce product using WordPress REST API

The new api’s documentation can be found here Woocommerce Rest API And you can create a Woocommerce product by posting data to the wp-json endpoint /wp-json/wc/v1/products (Documentation Here) $data = [ ‘name’ => ‘Premium Quality’, ‘type’ => ‘simple’, ‘regular_price’ => ‘21.99’, ‘description’ => ‘Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis … Read more

node-wpapi: how to handle authentication?

I’m the author of the node-wpapi library, thanks for checking it out. Unfortunately we do not currently support any external authentication scheme out of the box, because WordPress itself does not ship with any authentication scheme other than the cookie/nonce option (which doesn’t work with external apps, as you describe). There are plugins for authenticating … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)