Add Pinterest’s “Pin It” button to WordPress

This tutorial will show you how to add Pinterest’s Pin-It button to WordPress witout installing a plugin.

With this code you will be able to add the Pin It button to your posts. It will pull the first image from your post to be pinned and link to the post’s URL. The description will be the title of the post.

We have to add two snippets, one function to functions.php and one code in single.php to show the button.

Add the following code in your functions.php:

function pin_it() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_img = $matches [1] [0];
  if(empty($first_img)){ //Defines a default image
    $first_img = "/images/default.jpg";
  }
  return $first_img;
}

The function is inspired by WPrecipes.com.

If there is no image in your post the function will pull the default image /images/default.jpg. You can change the default image to whatever you would like.

Place the following code where you want the Pin It button to appear, it should be inside the loop in single.php. If you want to display the button on your homepage you have to add the code in index.php.

<a href="http://pinterest.com/pin/create/button/?url=<?php echo get_permalink(); ?>&media=<?php echo pin_it() ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="vertical">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

If you would like to add a horizontal button instead of the vertical button, change count-layout=”vertical” to count-layout=”horizontal”.

The vertical Pin It button looks like this:

Pin It

10 Social Media Tips

Are you considering to start using social media in your business communication? In this posts I will give you a couple of basic tips before you start.

  1. Where are your target audience? Which social networks do they use? Where can you participate in conversations? Twitter? Facebook? Youtube? Listen, search and find!
  2. Search and find what your audience are saying about your company? Do they like you? What are they saying about your competitors?
  3. Think like a business – Define goals and make a plan for your communication.
  4. Learn – Try to understand changing trends and patterns. Explore the channels and try to keep one step ahead of the curve.
  5. Build relationships – Social media is about building relationships.
  6. Use a blog instead of a static website. In the blog , you and your employees can write and / or post videos and share your knowledge to your visitors. Update the blog regularly, once or twice a week is enough to maintain a dialogue.
  7. Be relevant – Do not share what you had to lunch or what tv-series you are watching. Share knowledge, market trends and other valuable insights to your customers.
  8. When a visitor comments on a post, answer them, even if it is a critical comment.
  9. Keep track of what other blogs write about you and comment on other blogs.
  10. It takes time – It takes a lot of time and resources to build an effective network. Start small and grow gradually!
Join the conversation!

How to make your press release Twitter friendly

Why should you make your press release Twitter friendly?

A couple of weeks ago PR Newswire and Crowd Factory analyzed press releases and the activity around them. According to their research, 48 percent of press release activity happens on Facebook and 37 percent on Twitter but the sharing on Twitter results in 30 percent more views.

The research also found that videos and photos drive more traffic to a press release than plain text. If you add a photo to your press release the engagement increased  by 14 percent.

Take a look at the numbers in the infographic below!

How do you make your press release more Twitter friendly?

  1. Headline –  Your press release need to have a headline in the range of 100-120 characters. A tweet have a limit on 140 characters and if your headline is about 100-120 characters there is room for a user to add a little comment in the tweet. But your headline still need to give the people enough information about what the press release is about. Make your headline newsworthy, eye-catching, informative and about 100-120 characters.
  2. Include stats and facts – People love stats and facts but the numbers must be relevant for the press release. Facts about horses in a press release about dog food isn’t a good idea.
  3. Use Hashtags - Try to use hashtags  in your press release.
  4. Make quotes tweetable - Just like numbers people love quotes. Add an interesting quote in your press release and make it tweetable.
  5. Include pictures and video – Pictures and videos add a value to your press release and make your audience more interested in the content.

How to make your press release SEO friendly

With SEO your press release will get increased visibility and more views. It is an easy way to get more traffic but before you start optimizing your press release I want to point two things out, You need a good story to get visitors to read and never forget that you are writing for humans, don’t overdo your optimization.

How can you make your press release more SEO friendly?

  1. Release length - The optimal length for a press release is generally 400-600 word. This length is easy for readers to digest and comprehend.
  2. Headline - You need a catchy headline and try to include at least one relevant keyword phrase that your audience search for and if it’s possible in the beginning. Reduce unnecessary words in your headline.
  3. Tags - If you use a distribution partners then you can tag your press release with relevant keywords.
  4.  Use Keywords Try to use important keywords in your headline and text but don’t overdo it. Try using Googles keyword search tool to make it a little easier to find relevant keywords. You can also use Google Insights for Search to evaluate and discover popular variations. Remember that you should know your keywords before you start to write your press release.
  5. Use Anchor links – Try to include anchor text links with your keywords. It will drive viewers to your web site but it is important that you link to a site that is relevant to the press release. Also try to link to others pages than your homepage on your site. The links can deliver significant SEO benefit to the web site you’re linking to. Don’t overdo it, 3-4 links per press release is enough.
  6. Optimize your summary - The first 200-250 words of your press release is important.  It´s important for your ranking but if your content is not interesting in the beginning the reader will stop reading the release. Try to have your keywords and important phrases in the beginning. Is you use a distribution partner, the summary is often used as Meta description.
  7. Newsworthy - The most important thing is to be newsworthy and the content should be the content that interests your audience not the content that interrupts them. Do you have a good story? If not, no one will read and SEO won’t help you.

WordPress Maintenance Mode

Sometimes you need a quick maintenance mode for WordPress. Instead of installing a plugin, you can use this snippet and comment it out when you don’t want it switched on anymore. It will display the following text for visitoris trying to reach your site: Maintenance mode. Our site is currently undergoing scheduled maintenance. Please try back in 10 minutes. Sorry for the inconvenience.”

Add the following snippet to your functions.php to switch to maintenance mode:

function maintenace_mode() {

if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
wp_die('Maintenance mode. Our site is currently undergoing scheduled maintenance. Please try back in 10 minutes. Sorry for the inconvenience.');
}
}
add_action('get_header', 'maintenace_mode');

Don’t forget to remove the snippet when your are done!

Mary Blair Google Doodle

Todays Google Doodle honors the former Disney character and concept artist Mary Blair. She was born on October 21, 1911 and today would’ve been her 100th birthday. In the 50′s Mary Blair was contributing on several animated films including CinderellaPeter Pan and Alice In Wonderland . She passed away in 1978.

You can read more about Mary Blair on Wikipedia.