add custom field image to twitter card

#324298
  • Resolved Raul Pina
    Rank Math free

    Hello!

    How can I add a custom field image (created with jetengine) to twiiter card instead of using a feature image?

    I add %customfield(imatge-principal)% to the post type “Image Custom Fields”

    Btw in this case (test page) the image on the twitter doesn’t appear.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    To change this you need to edit the following filter to your specifications: https://rankmath.com/kb/filters-hooks-api-developer/#change-opengraph-image

    ​​​​​​​Here’s an example of adding the image from a custom field called twitter-image:

    
    add_filter( "rank_math/opengraph/twitter/image", function( $attachment_url ) {
        $twitter_image = get_post_meta(get_queried_object_id(), 'twitter-image', true);
    
        if ($twitter_image) {
            $twitter_image = $attachment_url;
        }
    
        return $attachment_url;
    });
    

    Hope this helps solve your issues.

    Don’t hesitate to get in touch if you have any other questions.

    Hello again.

    We will be using feature image instead. Thanks for the help.

    IN the mean time we had inserted a default image to social media.
    It appears on facebook. But on twitter it does not.

    What can it be?

    https://pasteboard.co/wFk4nn8fOeOs.png

    Thanks

    Prabhat
    Rank Math agency

    Hello,

    I tested the URL on Twitter and the correct image seems to be showing.

    Please clear your website and browser’s cache and see if that helps.

    Let us know how that goes.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘add custom field image to twitter card’ is closed to new replies.