featured_image in post published via API only showing after pressing “Update”

Your test-3 page does not appear to have a featured image. Should it have? Is it because the post has not yet been updated by the editor? I’m assuming this was a post made via the API.

Your workflow is unclear. What is triggering the API call to publish a post? You mention two different themes. Are these pages on separate WP sites? Are you saying the featured image is not visible on the front end until you manually update the post? This sounds like an issue with the Dante theme. I recommend seeking suggestions through that theme’s dedicated support channel.

I’m about to have this resolved, just an hour of work more. It relates to either a plugin or the theme requiring additional metadata for displaying the featured image. I will share solution asap.

The issue was the theme “Dante by Swift Ideas.”

This theme adds many “Meta options” to the editor as seen here:

However, some of these metadata require to be set for certain functions to work. In this case, “sf_detail_type” must be set to “image” for the featured image to show in posts.

Hence, I added ‘meta’ => $metaData, where $metaData[‘sf_detail_type’] = ‘image’;

For this to work with REST API, I had to build a custom plugin to add this metadatum to be accepted:

<?php
/*
Plugin Name: Add meta tags to REST-API
Description: Adds the specified meta tags to the REST-API for supporting posting via same.
Version: 1.0
Author: None
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

function register_my_meta() {
register_meta('post', 'sf_detail_type', array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function() {
return current_user_can('edit_posts');
}
));
}
add_action('init', 'register_my_meta');

Posting now works and the issue has been resolved.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer