Last active
January 19, 2017 23:16
-
-
Save daviddarnes/5735237 to your computer and use it in GitHub Desktop.
Open Graph meta information for Facebook and Google+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Open graph meta --> | |
<meta property="og:type" content="website"> | |
<meta property="og:site_name" content="<?php echo site_name(); ?>"> | |
<?php if(is_homepage() == true) : ?> | |
<meta property="og:url" content="http://websiteaddress.com"> | |
<meta property="og:title" content="<?php echo site_name(); ?>"> | |
<meta property="og:description" content="<?php echo site_description(); ?>"> | |
<?php else: ?> | |
<meta property="og:url" content="<?php echo "http://websiteaddress.com/" . current_url(); ?>"> | |
<meta property="og:title" content="<?php echo page_title('Page can’t be found'); ?> - <?php echo site_name(); ?>"> | |
<meta property="og:description" content="<?php if(strlen(article_description())) : echo article_description(); else: echo site_description(); endif; ?>"> | |
<?php endif; ?> | |
<!-- If you have any image custom fields --> | |
<?php $thumbnail = article_custom_field('thumbnail'); | |
if ( !empty($thumbnail) ) : ?> | |
<meta property="og:image" content="<?php echo "http://websiteaddress.com" . $thumbnail; ?>"> | |
<?php else: ?> | |
<meta property="og:image" content="<?php echo "http://websiteaddress.com" . theme_url('img/logo.png'); ?>"> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cinoyter -- I had a similar issue with is_homepage(); Thanks for taking the time to post a fix. I also found this write-up that shows how to add support Twitter Cards and Search Engine MicroData:
http://lug.io/blog/posts/adding-semantic-markup-to-anchor-cms