Last active
April 29, 2020 12:27
-
-
Save vanaf1979/dd274f00151c6d51bf5103928765f5b4 to your computer and use it in GitHub Desktop.
Add custom (ACF) fields to the WordPress Rest Api. https://since1979.dev/add-custom-acf-fields-to-the-wp-rest-api/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* get_featured_image_api_field. | |
* | |
* Callback function for register_featured_image_api_field | |
* Fetch and return the the featured image for a post. | |
* | |
* @see https://since1979.dev/add-custom-acf-fields-to-the-wp-rest-api/ | |
* @uses get_the_post_thumbnail_url() https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/ | |
*/ | |
function get_featured_image_api_field($post) | |
{ | |
return get_the_post_thumbnail_url($post['id'], 'post-thumb-small'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment