in Articles

Paulund Is Now On Facebook

Facebook Shop It's been a long time coming but Paulund now has it's own Facebook page, which depending on the amount of people that join it will be the most updated page out of all my social media pages. Like Paulund On Facebook Paulund has had a Twitter account since the start but I didn't really see the need for a Facebook page as thought the subject of this blog will not be suited for Facebook but how wrong was that. Paulund will continue to use Twitter as much as before because we have a nice following of people and more new people coming to us everyday from Twitter but I would also like to start talking to people who are on Facebook and not Twitter. I also like the fact that I'm not limited to the amount of characters in a post as I am on Twitter, this gives me much more room to add a comment to a page when I post it on Facebook. I know you still don't get as many characters on posts as you get from Google plus (which I am still using) but you get enough to explain the link I am sharing. The main reason for creating a Facebook page is to reach out more to people that follow this blog, Facebook is the biggest social media network with over 800 million people on there so it would be silly not to be on there. So why not stay updated to the latest changes at Paulund by liking us on Facebook. Like Paulund On Facebook## Open Graph

When getting Paulund ready to get on to Facebook I had to quickly learn about the open graph system that Facebook have in place, this is the API they use to get data from your site. When a website is submitted to Facebook, they can automatically populate the share box with a thumbnail image, title and description all these are defined by using the Facebook open graph meta tags. Most other websites will just search for the meta title and description tags but for Facebook you need to add in the open graph tags, this is so you can choose different things to be displayed on Facebook when someone shares your links. ### Open Graph Tags

These are the open graph tags Paulung is currently using.

<meta property="og:title" content="" />
<meta property="og:type" content="article" />
<meta property="og:image" content="" />
<meta property="og:url" content="" />
<meta property="og:description" content="" />
<meta property="og:site_name" content="Paulund" />

If you are using Wordpress for your website then you would want these to appear on each post with the content pre populated so don't have to change anything. I tried out a few plugins that supposed to do this for you but none of them seem to work the way I wanted them to. All I wanted was the all these to be populated from the content that is already in the post and the description to have the first 55 characters of the post. As none of the plugins did this then I looked into how can I add these myself and found this nice code snippet you can add to your functions.php file which will add this information for you. ## Add Open Graph Tags To Wordpress

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 {    
            $image = ''; // Change this to the URL of the logo you want beside your links shown on Facebook
        //$description = get_bloginfo('description');
        $description = my_excerpt( $post->post_content, $post->post_excerpt );
        $description = strip_tags($description);
        $description = str_replace("\"", "'", $description);
<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 $description ?>" />
<meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />

<?php   }

function my_excerpt($text, $excerpt){

    if ($excerpt) return $excerpt;

    $text = strip_shortcodes( $text );

    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]&gt;', $text);
    $text = strip_tags($text);
    $excerpt_length = apply_filters('excerpt_length', 55);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $words = preg_split("/[\n
     ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    if ( count($words) > $excerpt_length ) {
            $text = implode(' ', $words);
            $text = $text . $excerpt_more;
    } else {
            $text = implode(' ', $words);

    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email