Posted By

certainlyakey on 06/09/12


Tagged

wordpress meta facebook opengraph


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

al3rt
clacwebstudio


Facebook OpenGraph tags for a Wordpress site


 / Published in: PHP
 

To be used in the header.php

  1. <meta property="fb:admins" content="[Your FB app ID]" />
  2.  
  3. <!-- if page is content page -->
  4. <?php if (is_single()) { ?>
  5. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  6. <meta property="og:url" content="<?php the_permalink() ?>"/>
  7. <meta property="og:title" content="<?php single_post_title(''); ?>" />
  8. <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
  9. <meta property="og:type" content="article" />
  10. <?php endwhile; else: endif; ?>
  11. <!-- if page is others -->
  12. <?php } else { ?>
  13. <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
  14. <meta property="og:description" content="<?php bloginfo('description'); ?>" />
  15. <meta property="og:type" content="website" />
  16. <?php } ?>

Report this snippet  

You need to login to post a comment.