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

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x