How to get featured image in WP rest api

You can add featured image to REST API by adding this code to your theme’s functions.php // Add featured image to REST API add_action(‘rest_api_init’, ‘register_rest_images’ ); function register_rest_images(){ register_rest_field( array(‘post’), ‘fimg_url’, array( ‘get_callback’ => ‘get_rest_featured_image’, ‘update_callback’ => null, ‘schema’ => null, ) ); } function get_rest_featured_image( $object, $field_name, $request ) { if( $object[‘featured_media’] ){ $img … Read more

Add image to each podcast series (or category) in headless WordPress instance [closed]

I think it would be prudent to create a new custom taxonomy now named podcast in order to categorize your episodes separate from other content. Whether using a custom podcast taxonomy or generic categorys, taxonomies do not support attached media or featured images out of the box. You’ll likely need to store a media attachment … Read more

How to add/edit advanced custom fields on custom post type’s WordPress REST API?

I think the only thing missing here is an update_callback in the call to register_rest_field. register_rest_field( ‘note’, ‘noteLink’, array( ‘get_callback’ => function(){ return get_field(‘page_link’); }, ‘update_callback’ => function( $value, $post ){ update_field(‘field_619dacfd37924’, $value, $post->ID ); } )); An important part of that according to ACF docs is using the field key to update the value … Read more

How to store and return json in a (custom) post meta field

I’m not exactly sure what are you really trying to do, but anyway, I hope these help? If you send the meta value as an object, e.g. video: {“foo”:”bla blah”,”bar”:1234} in JS, then note that WordPress will serialize the value (or convert the object to a serialized string) before it’s saved to the database. See … Read more