Create a new post using rest api and save featured image using an external image url

Instead of using wp_ajax_ (i.e. admin-ajax.php), how about adding a custom REST API field and then using its update_callback, download the remote image and set it as the post featured image? Working Example add_action( ‘rest_api_init’, ‘wpse_381217’ ); function wpse_381217() { register_rest_field( ‘post’, ‘featured_image_url’, array( // If you don’t want to expose the field in the … Read more

How to create a post using REST API with sending data as a JSON body?

That’s strange, but nonetheless, you should know that whether you use cURL, PHP, JS, etc., if you’re sending a JSON data, then you should set the Content-Type header to application/json. And via the cURL command line, you can use the -H option: curl –user “username:password” -X POST \ -H “Content-Type: application/json” \ -i https://example.com/wp-json/wp/v2/posts \ … Read more

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