• Resolved hbrobjerg

    (@hbrobjerg)


    I have migrated a working code for posting via the REST API from one wordpress page (“Page 1”) to another wordpress page (“Page 2”).

    On Page 1, everything works. Theme is “AstraVersion: 4.6.13 by?Brainstorm Force

    On Page 2, everything works EXCEPT this; the featured image is not showing in the new post. However, all it takes to make it show is to go to the post editor and press “Update,” nothing else, i.e., the image is already added to the post as the featured image, but for some reason not showing in the post before the “Update” button is pressed manually.

    ChatGPT suggests that some kind of hook is required by the theme that is only activated through manually pressing of the “Update” button.

    Theme on Page 2 is “Dante Version: 3.5.25 by?Swift Ideas.” I cannot test changing the theme as this breaks the page (critical error).

    I have tried to log hooks when pressing update, but I am not a programmer and I have not been able to find any hooks.

    I have tried disabling and enabling relevant plugins with no difference.

    Any suggestion will be highly appreciated, as I have run out of things to try.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    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.

    Thread Starter hbrobjerg

    (@hbrobjerg)

    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.

    Thread Starter hbrobjerg

    (@hbrobjerg)

    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.

    @hbrobjerg

    I have been using their Cardinal theme and unfortunately for me, I’m not even sure if Swift Ideas is even actively functioning as a business anymore. They don’t seem to push theme or framework updates and the contact email [email protected] is not receiving emails anymore either. The last time I submitted a support ticket through their support ticket system, I never received a response from Ed (which I used to). Glad you were able to get your issue resolved with your theme.

    • This reply was modified 3 months, 4 weeks ago by Drew75.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.