Set Meta Box image for Open Graph

You have a Meta Box image_advanced field and want to use the first image as the Open Graph image.

add_filter( 'slim_seo_open_graph_image', function( $image ) {
    if ( ! is_singular() ) {
        return $image;
    }
    $images = rwmb_meta( 'gallery' );
    if ( ! empty( $images ) ) {
        $image = reset( $images );
        return $image['full_url'];
    }

    return $image;
} );

🔥 HOT: Interested in boosting your WordPress SEO? My Slim SEO plugin is a super lighweight and automated plugin that handles most the hard work for you: meta tags, sitemap, redirection, schema & link building.

👉 Have a look and you will love it: wpslimseo.com

Copyright © 2024 Deluxe Blog Tips. All rights reserved.

My products: Meta Box | Slim SEO