Build Your Own Business Website header image

How to Add Facebook Open Graph Tags in Thesis – Part 4 – 1 Week Later Follow Up

Difficulty Level -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

One of our members was having a trouble with Facebook not showing the image after adding the Facebook open graph tags. In this session, we discuss how Facebook works with images and give the code that we use on byobwebsite.com. The code is shown below.

This is the exact code we use on byobwebsite.com

/*******************************************************************************
* This function adds Facebook Open Graph tags to the head
********************************************************************************/

function byob_add_facebook_open_graph_tags() {
 if (is_singular()) {
 global $post;
 setup_postdata($post);
 $image = get_post_meta($post->ID, 'thesis_post_image', $single = true);
 if (!$image)
 $image = 'https://www.byobwebsite.com/wp-content/uploads/2012/02/aweber-header.jpg';
 
 $dirty_excerpt = get_the_excerpt();
 $clean_excerpt = wp_strip_all_tags($dirty_excerpt, true);
 ?>
 <meta property="og:title" content="<?php the_title(); ?>" />
 <meta property="og:type" content="article" />
 <meta property="og:image" content="<?php echo $image; ?>" />
 <meta property="og:url" content="<?php the_permalink(); ?>" />
 <meta property="og:description" content="<?php echo $clean_excerpt; ?>" />
 <meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />
 <meta property="fb:admins" content="byobrick" />
 <?php }
}
add_action('wp_head', 'byob_add_facebook_open_graph_tags',99);
0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
THIS IS A LIMITED TIME OFFER!
Subscription Options
0 comments… add one

Leave a Comment