1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Facebook Meta Tags for Index (static image)?

Discussion in 'Web Design' started by directaxcess, Sep 19, 2011.

  1. directaxcess

    directaxcess Power Member

    Joined:
    Sep 12, 2011
    Messages:
    780
    Likes Received:
    154
    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)?
     
  2. Crazy

    Crazy Jr. Executive VIP

    Joined:
    Jun 13, 2009
    Messages:
    640
    Likes Received:
    319
    Occupation:
    VB, C#, XHTML, CSS, PHP, MySQL, JavaScript, jQuery
    Location:
    Everywhere
    <meta property="og:image" content="url_or_filename.jpg" />
     
  3. directaxcess

    directaxcess Power Member

    Joined:
    Sep 12, 2011
    Messages:
    780
    Likes Received:
    154
    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.
     
  4. directaxcess

    directaxcess Power Member

    Joined:
    Sep 12, 2011
    Messages:
    780
    Likes Received:
    154
    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).
     
  5. Crazy

    Crazy Jr. Executive VIP

    Joined:
    Jun 13, 2009
    Messages:
    640
    Likes Received:
    319
    Occupation:
    VB, C#, XHTML, CSS, PHP, MySQL, JavaScript, jQuery
    Location:
    Everywhere
    Sorry, I didn't fully understand your question.

    Good job, I think that's a good solution.
     
  6. pavan

    pavan Elite Member

    Joined:
    Mar 30, 2008
    Messages:
    1,603
    Likes Received:
    432
    you can edit index.php in your theme folder and add the following code

    Code:
    <meta property="og:image" content="yourimagepath"/>
     
  7. directaxcess

    directaxcess Power Member

    Joined:
    Sep 12, 2011
    Messages:
    780
    Likes Received:
    154
    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?!?