How to Fix The Thumbnail When Sharing your Posts on social media | Using 4 Methods

Опубликовано: 23 Октябрь 2024
на канале: Tech support
4,011
31

LIKE || SHARE || SUBSCRIBE

In this video I am going to show you that how you can fix the thumbnail issue of your posts sharing at the facebook.


If you want to Install the Wordpress then watch my video.    • How to Install Wordpress on Wamp  

For to Install ASTRA THEME Watch this Video.    • How To Setup Astra Theme Full Tutoria...  

If you have not Installed the MyListing theme yet then watch my video.    • How to Install and Setup MyListing Theme  

How to download the images and Video file without using IDM watch this video:    • How To Download Images and Video From...  


Here is the code for functions.php:

function insert_og_image() {
global $post;
if(!has_post_thumbnail( $post-)ID )) { //the post does not have featured image, use a default image
$default_image= get_template_directory_uri()."assets/images/defaultshareimage.jpg"; //replace this with a default image on your server or an image in your media library
echo '(meta property="og:image" content="' . $default_image . '"/)';
}
else{
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post-)ID ), 'medium' );
echo '(meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/)';
}
}
add_action( 'wp_head', 'insert_og_image', 5 );

For More inquiries: [email protected]
OR
Comment us below.

Thanks