Category archives: open graph

 

 

0

Add Facebook Open Graph Tags To WordPress

When a link is shared on Facebook it will be crawled to get the page title and description. The way Facebook will get this information is to search for Open Graph tags, these are meta tags added to your page with a title, description and image data. This data is then used to populate the Facebook status box when someone shares your link. WordPress doesn’t come with the functionality to add Facebook open graph meta tags, but you can use the below snippet to add open graph meta tags to all your posts. Simply add the following code to your functions.php page and it will automatically create the Facebook open graph tags for you, so no need to have the Facebook plugins on your WordPress site. // Facebook Open Graph add_action('wp_head', 'add_fb_open_graph_tags'); function add_fb_open_graph_tags() { if (is_single()) { global $post; if(get_the_post_thumbnail($post->ID, 'thumbnail')) { $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_object = get_post($thumbnail_id); $image = $thumbnail_object->guid; } else { […]

Read more