We are all encouraging people to share our content on social media. But have you checked out how good your content looks when it is shared?
Facebook and Twitter will make assumptions when they see your content to try and share it. They do not always find the right image or message. However, there is a way to help them find the right content and that is to include special meta codes on your pages.
Hopefully, these are already in use from a social plugin or tool already installed. The way to find out is to view the source code of one of your pages. I suggest you check out a post or page, because that is the sort of page most likely to benefit you being shared.
When you look at the course code you are looking for special meta tags with twitter and facebook entries. Here are the tags for this very page.
<!-- fb and twitter --> <meta property="og:title" content="Is your site socially aware?"/> <meta property="og:description" content="Click here to read more from our blog."/> <meta property="og:type" content="article"/> <meta property="og:url" content="https://wpbusinessclub.com/?p=1085"/> <meta property="og:site_name" content="WP Business Club"/> <meta property="og:image" content="https://wpbusinessclub.com/wp-content/themes/wpbusinessclub2017/img/header.png"/> <meta property="og:type" content="article" /> <meta property="article:section" content="News" /> <meta property="article:published_time" content="2017-04-24T17:05:01+00:00" /> <meta property="article:modified_time" content="2017-04-24T17:05:00+00:00" /> <meta property="og:updated_time" content="2017-04-24T17:05:00+00:00" /> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@WPBusinessClub"> <meta name="twitter:creator" content="@WPBusinessClub"> <meta name="twitter:title" content="Is your site socially aware?"/> <meta name="twitter:description" content="Click here to read more from our blog."/> <meta name="twitter:image" content="https://wpbusinessclub.com/wp-content/themes/wpbusinessclub2017/img/header.png"/>
You can compare your content page with this and see if you have the full contingent.
If you do not have these tags on your site, then there are a number of ways to add them. You may find they are an option on a plugin you are already using. They may be a feature of your theme. If not then there is an easy way to add them.
If you are using a child theme, you can add them to your functions.php file. A simple piece of code will look up the information from your post or page. If you don’t have a featured image it will allow you to specify a logo.
If you don’t want to edit your theme, then we have had a simple plugin written to put everything in for you. The plugin does have some settings which you can use to specify your twitter name etc. it will then add the code to your posts, and pages. We don’t provide it for the home page, or archive pages because it is not clear on these, what you want to promote. – And the whole idea of this was to keep it simple.
One final piece of advice. Make sure you publish your post before you share it. If you attempt to jump the gun and try to share it when it is in draft form, Facebook and Twitter will not be able to pick up the information to share it correctly.
Warning The code follows…
Look away if you don’t like code. This can be dropped into the functions.php file and will work straight away. Just be sure to change the static values to your facebook and twitter credentials.
function wpbizclub17_twitter() { global $post; if(is_single()) { if(has_post_thumbnail($post->ID)) { $image_attributes = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium'); $img_src = $image_attributes[0]; } else { $img_src = get_stylesheet_directory_uri() . '/img/header.png'; } if($excerpt = $post->post_excerpt) { $excerpt = strip_tags($post->post_excerpt); $excerpt = str_replace("", "'", $excerpt); } else { // $excerpt = get_bloginfo('description'); $excerpt = "Click here to read more from our blog."; } ?> <!-- fb and twitter --> <meta property="og:title" content="<?php echo the_title(); ?>"/> <meta property="og:description" content="<?php echo $excerpt; ?>"/> <meta property="og:type" content="article"/> <meta property="og:url" content="<?php echo the_permalink(); ?>"/> <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/> <meta property="og:image" content="<?php echo $img_src; ?>"/> <meta property="og:site_name" content="WP Business Club" /> <meta property="article:section" content="News" /> <meta property="article:published_time" content="<?php echo get_the_date( 'Y-m-d' ).'T'; the_time( 'H:i:s' ); echo'+00:00'?>" /> <meta property="article:modified_time" content="<?php echo get_the_modified_date( 'Y-m-d' ).'T'.get_the_modified_time( 'H:i:s' ).'+00:00'?>" /> <meta property="og:updated_time" content="<?php echo get_the_modified_date( 'Y-m-d' ).'T'.get_the_modified_time( 'H:i:s' ).'+00:00'?>" /> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@WPBusinessClub"> <meta name="twitter:creator" content="@WPBusinessClub"> <meta name="twitter:title" content="<?php echo the_title(); ?>"/> <meta name="twitter:description" content="<?php echo $excerpt; ?>"/> <meta name="twitter:image" content="<?php echo $img_src; ?>"/> <?php } else { return; } } add_action( 'wp_head', 'wpbizclub17_twitter' );