How to add WP API and JS featured image attachment

I manage to solved it by adding this code (at the bottom) to the YOUR BLOG THEMES my path : wp-content/themes/twentysixteen/function.php: function ws_register_images_field() { register_rest_field( ‘post’, ‘images’, array( ‘get_callback’ => ‘ws_get_images_urls’, ‘update_callback’ => null, ‘schema’ => null, ) ); } add_action( ‘rest_api_init’, ‘ws_register_images_field’ ); function ws_get_images_urls( $object, $field_name, $request ) { $medium = wp_get_attachment_image_src( get_post_thumbnail_id( … Read more

Passing a borrowed nonce through Postman fails

For remote apps (cURL, Postman, etc.), or when not using the browser, you should use an authentication plugin like Application Passwords instead of sending the cookies. But if you’d rather send the cookies, then copy and send the WordPress logged-in cookie named wordpress_logged_in_<hash>. Example in cURL: curl -H “X-WP-Nonce: <nonce>” -X POST https://example.com/wp-json/wp/v2/posts -d “Data … Read more

How can I cache WordPress Rest API Response

You should create a new instance from WP_REST_Response to set the Cache-Control value. <?php register_rest_route(‘wp/v2’, ‘/your_endpoint’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘function_callback’, )); function function_callback($data) { $response = array( 1,2,3,4,5,6,7,8 ); $result = new WP_REST_Response($response, 200); // Set headers. $result->set_headers(array(‘Cache-Control’ => ‘max-age=3600’)); return $result; } Click here to get more info about directives.

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