Facebook Meta Tags for Index (static image)?

directaxcess

Senior Member
Joined
Sep 12, 2011
Messages
825
Reaction score
158
I just about got the new website set up and ready to go but had a question that's been bugging me. I'm using SEO by Yoast to add the META tags to my blog (including Facebook opengraph tags), and it works fine for posts but for the index (or home page), if you were to share my website link on your Facebook wall, it would just import the images from the front page (the post images). Is there anyway I can define the image for index.php as a static image (my logo)?
 
<meta property="og:image" content="url_or_filename.jpg" />
 
I know that, but that would define it for ALL pages. I need to make a function for if is_home, just wondering how to code that. Im going to try some code out and see what works and will post here if I need anymore help.
 
In case anyone was wondering how to do this, I figured it out. Just add a conditional tag to your header.php file in WordPress:

<?php if (is_home()) : ?>
<meta property="og:image" content="yourimagepath"/>
<?php endif ?>

You can also use a function to add the og:image to your home, front or index page (same thing for my blog but may not be for yours).
 
Sorry, I didn't fully understand your question.

Good job, I think that's a good solution.
 
you can edit index.php in your theme folder and add the following code

Code:
<meta property="og:image" content="yourimagepath"/>
 
See, I did that AND I've added the conditional code but Facebook just can't seem to pick up the meta tags properly. For the single posts its working fine with the SEO by Yoast plugin, but its not adding the og:image tag in home, and its not even picking up the description that's coming up for home. Weird?!?
 
Back
Top