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( $object->id ), 'medium' );
$medium_url = $medium['0'];
$large = wp_get_attachment_image_src( get_post_thumbnail_id( $object->id ), 'large' );
$large_url = $large['0'];
return array(
'medium' => $medium_url,
'large' => $large_url,
);
}
Hope this help someone.
Related Posts:
- How to submit a button automatically after every scheduled hours?
- AJAX request from Chrome Extension to WordPress Website
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- merge wp rest api query to get posts per category does not work
- post values to custom post type which has advanced custom fields
- Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable
- Custom WP rest api endpoint only working on non https?
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- jQuery’s .on() method combined with the submit event
- Is there a JavaScript API? How to access public and private data in JS?
- Using Backbone with the WordPress AJAX API
- How do I cache (core) API requests?
- Retrieving pages with multiple tags using REST API
- Including WordPress in RESTful API
- REST API endpoint for elasticpress autosuggest
- How to link WordPress heartbeat to ajax form
- Gutenberg – how to correctly perform ajax request on backend
- Basic WordPress AJAX Call
- Drag and drop multiple file upload using Ajax WordPress
- How to securely add an Ajax button to a WP Admin page?
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- WP REST API route request explain
- Confused on AJAX submit form through page template
- Create post with REST API in php with file_get_contents
- Solve cors problem using rest api or ajax
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- WordPress AJAX Call Not Return Result
- WP-API and Basic Auth returning 403 on POST but not GET
- Is there a hook to process a backbone restful PUT request inside wordpress?
- Get all tags not just first 10 with wp api 2.0
- Implementing an AJAX POST API call in wordpress
- I have to post data by AJAX in wordpress to another Website
- Identical wp_rest nonce returned from rest_api
- WordPress Admin AJAX Serialize
- Ajax Modal Flickers When Opened Multiple Times
- Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
- rest_no_route custom route
- Adding custom end points, No error line
- AJAX request randomly stop working and returns error 400
- How do I query posts by a sub value with the API?
- Exposing data using a custom WordPress API
- Bad request 400 from custom ajax call
- Use WP admin AJAX url to hide API key
- How to pass parameters from jQuery ajax into PHP function?
- I can’t get a return value from Ajax
- WordPress AJAX return 0 – My case
- Ways to load admin-ajax faster without initializing all plugins?
- Display posts from another site using REST API in an asynchronous manner
- WP AJAX post filter > do something with empty value
- 403 error When i send ajax request on WordPress website
- AJAX jQuery post frontend returning failed to load resource status 400
- How to make a fetch() POST request to wordpress rest api?
- Load more posts in the same category – Ajax + Timber
- Creating a WordPress Post via REST API – HTML or Markdown?
- How to jQuery Ajax show new data from successful insert?
- How can I call an api before user login
- Problems with wordpress nonces in Ajax call
- Ajax call in WordPress – unable to display the data on the page
- Get post content and show it in a div
- Output multi-steps form results in same page
- Full Front End, AJAX comment system and comment reply script
- WP REST API and Access-Control-Allow-Origin
- What WP-API authentication method should I use to interact with anonymous / not-logged visitors?
- WP AJAX API with JS file
- Ajax Favorite from foreach (how to specify which result result is processed)
- WordPress REST API – get custom taxonomy category posts
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- REST public POST giving 403 forbidden nginx
- javascript onClick update user_meta from jquery.ajax
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- Escape commas in REST API
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- My function containing a mysql query launched by ajax is not working in wordpress. What am I missing?
- Remove unwanted fields from WP API response
- JS global variable doesn’t update
- WordPress API “code”:”rest_no_route” with Custom Route
- 400 Bad Request getting on AJAX Call
- 404 error custom post type rest api
- Adding Amchart Interface to WordPress API
- jQuery AJAX url wit variable
- React to AJAX adding to the page
- Loop through WordPress API response errors
- Updating Jquery object with newly created elements after AJAX call
- Deleting media using the WordPress Rest API
- How to pass array from jQuery to PHP with AJAX in WordPress?
- Ajax call not working anymore
- Can’t get next post info with ajax
- Extending the API I created to return category names
- How to inject data content from external json into a modal, using UIkit?
- Ajax by worpdress affects called jquery inside template file
- Passing form data via AJAX to REST API And displaying results
- WordPress Ajax send response on every iteration of a loop
- how reduce fetch/XHR response time
- External api call using wordpress
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- How to update my jquery/PHP function to add/remove user as favorites in (WordPress) users list
- Adding Microsoft Teams Incoming Webhook to WordPress, Problem with Rest Route?
- Woocommerce API for calling products by Category ID
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?