Get Image URL instead of Attachment Id in Rest API

You can modifiy REST API responses in themes functions.php like this. 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( $object->id ), ‘medium’ ); $medium_url = $medium[‘0’]; $large = wp_get_attachment_image_src( … Read more

What are the Oembed Links For?

Those are links for the wordpress “self” oEmbed. It provides the URLs needed to enable embeding the content of the wordpress site in other sites and they are resuired for oEmbed Discover You are right that they are for other sites to consume your content, and if you don’t care about it, just remove it. … Read more

using wp_remote_get instead of file_get_contents [duplicate]

If you need to send a JSON response, then there’s a set of functions for that. In case you need that for an AJAX callback: wp_remote_retrieve_response_message() wp_remote_retrieve_response_code() wp_send_json_success() wp_send_json_error() wp_send_json() Would finally be something like that: $request = wp_remote_get( ‘http://example.com’ ); $response = wp_remote_retrieve_body( $request ); if ( ‘OK’ !== wp_remote_retrieve_response_message( $response ) OR 200 … Read more

Sending JSON string through wp_remote_post()

Try setting the data_format parameter in your request like so: $data = wp_remote_post($url, array( ‘headers’ => array(‘Content-Type’ => ‘application/json; charset=utf-8’), ‘body’ => json_encode($array_with_parameters), ‘method’ => ‘POST’, ‘data_format’ => ‘body’, )); It looks like the format may be defaulting to query, in which case WordPress attempts to format the data using http_build_query, which is giving you … Read more

JSON and escaping characters

This is not a bug in either implementation. There is no requirement to escape U+00B0. To quote the RFC: 2.5. Strings The representation of strings is similar to conventions used in the C family of programming languages. A string begins and ends with quotation marks. All Unicode characters may be placed within the quotation marks … Read more

How do I make a JSON object with multiple arrays?

On the outermost level, a JSON object starts with a { and end with a }. Sample data: If the JSON is assigned to a variable called data, then accessing it would be like the following: Another approach (using an associative array for car models rather than an indexed array): Edit: Correction: A JSON object starts with { and ends … Read more

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