presales question about ACF

#937150
  • can the post/page ACF image field be pulled into the Social media appearance as a preset/default?

    I have a site built already, many pages, can i add a default image for each page – without editing every single page?
    (the default image would reference an ACF image field that is displayed already on each page)

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Yes, you can use this filter to update the social media image (Opengraph) from your custom field:

    add_filter( 'rank_math/opengraph/facebook/image', 'change_opengraph_image_custom_field' );
    
    function change_opengraph_image_custom_field( $attachment_url ) {
        global $post;
        if (is_page()) { //update to match your page/post type
            $attachment_url = get_field( 'custom-field-name', $post->ID ); //update to the actual custom field name
        }
        return $attachment_url;
    }

    Here’s how you can add filter/hook to your WordPress site:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.