Controlling which picture is used for FaceBook thumbnail

Published by Fudgy McFarlen on

The following code inserted into the header.php passes off the thumbnail in the article.

 &lt;?php<br />
	if (is_home()) {<br />
	echo &#39;&lt;meta property=&quot;og:image&quot; content=&quot;http://www.amarketplaceofideas.com/wp-content/uploads/2013/04/Wavy-Arm-Guy.jpg&quot;/&gt;&#39;;<br />
	}<br />
	elseif (function_exists(&quot;has_post_thumbnail&quot;) &amp;&amp; has_post_thumbnail() &amp;&amp; !is_home() ) {<br />
	$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), full ); ?&gt;<br />
	&lt;/p&gt;<br />
	&lt;meta content=&quot;&lt;?php echo $thumbnail[0]; ?&gt;&quot; property=&quot;og:image&quot; /&gt;<br />
	&lt;?php } ?&gt;<br />
	&lt;p&gt;<br />
	

Categories: PHPSoftware

1 Comment

Freemon SandleWould · April 30, 2013 at 5:55 am

Hey Banjo!  You do know you need to replace the default image link with your own right?  

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *