• Resolved Glennf

    (@glennf)


    I’m trying to add a featured image for my WordPress blogs RSS Feed as shown in the link to this message, but I want to use the Open Graph image tag image URL that is in all of my posts. For instance…

    <meta property="og:image:url" content="https://mysite.net/myimage.jpg"/>
    
    

    What would be the snippet code to use for this? Thanks!

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

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    I believe you’d want to put this meta tag in the site head, so you can add an action hooked to wp_head that uses get_the_post_thumbnail_url() to retrieve the post thumbnail, and if there’s one available, output the tag:

    add_filter( 'wp_head', function () {
    	$thumbnail_url = get_the_post_thumbnail_url();
    
    	if ( $thumbnail_url ) {
    		printf( '<meta property="og:image:url" content="%s">', esc_attr( $thumbnail_url ) );
    	}
    } );
Viewing 1 replies (of 1 total)
  • The topic ‘Show Featured Image in WordPress RSS Feed?’ is closed to new replies.