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

wp_localize_script escaping my url – fix or alternative

wp_localize_script() now uses json_encode() which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array. Better is an way to use json and default js possibilities from WP. At first, i add the options from the database via script and json_encode … Read more

Headless WordPress – Issue with plugin path

I understand the question and answer are from more than a year ago, but I just wanted to add some additional information in hopes it might be useful for future visitors of this Question. Recently, while setting up a Headless WordPress CMS with Roots Bedrock, I came across the same issue and solved it with … Read more

External API to WP

I’d recommend writing a simple plugin. Read through the Plugin Development Handbook, but it’s pretty easy. The only thing necessary for a plugin is the header with the Plugin Name. In the plugin, create a function that gets and stores in a WordPress transient the result of an API request. <?php /** * Plugin Name: … Read more

creating shortcode to pull json array

As per documentation on wp_remote_get() it doesn’t return you just the body of requested resource. Its return will be either the array of data or WP_Error object on failure. The simplest snippet to get to the body would be: $json = wp_remote_retrieve_body( wp_remote_get( $url ) ); PS it’s kinda weird to be doing this in … Read more

Customizer, change preview url when a control changes

Gonna have a go… say you have a theme option themeoption[id]… instead of setting transport refresh, set it to postMessage instead, and then add this code to create a callback that first gets the page URL via AJAX then sends that back to the previewUrl as you mentioned before refreshing… add_action(‘customize_preview_init,’preview_override_loader’); function preview_override_loader() { add_action(‘wp_footer’,’preview_override_script’); … Read more