RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (5.84%*) • Fixed: 5.39% (5.84%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.19%*) • Investment PI: 5.55% (6.02%*)

Add a Pinterest Save Button over Every Image in WordPress

Add a Pinterest Save Button over Every Image in WordPress

Pinterest is a free website that allows users to upload, save, sort, and manage images - known as pins - and other media content (such as videos and images) through collections known as pinboards. Users can save individual pins to one of their own boards using the "Pin It" button on a website, with Pinboards typically organised by a central topic or theme. Users can personalize their experience with Pinterest by pinning items, creating boards, and interacting with other members. By doing so, the users "pin feed" displays unique, personalized results that give followers a visual insight into an individuals creative thought discovery or, for the case of advertisers, user consumer habits.

Pinterest is a social network that I haven't gelled with personally... but after a quick experiment with one of our smaller websites, there's little doubt that the service converts at a higher rate per user than the transient networks like Facebook and Twitter. Sadly, Pinterest is another traffic-generating network that cannot be ignored.

This article will show you how to add a PinIt Save Button over every image on your post or page. A subsequent article deals with how to add the Pinterest Save Button at the top and/or every post and/or page. Another scheduled article will show show you how to include a Follow, Pin, Board and Profile Widget in WordPress with shortcode.

Taking Control of Your Images

How important are images to your website's SEO? Short answer: very. If this is the case, why do we almost hurriedly import images into WP's library with what is often a disregard for important parameters such as title, description, alt tags, or even a relevant and descriptive filename? Adding image tags is often considered a tedious task with what is a perceived lack of importance or relevance to search engines - the truth of course is the opposite. Bottom line: add tags to every image you import into your WP library.

The Result

If you hover over the image below, and assuming we haven't removed the feature from our own site, a Pinterest Save button should present itself.

Add a Pinterest Save Button over Every Image in WordPress

Pinterest Screenshot, 30th November 2015

For those of our clients using our plugin (discussed below in brief), the shortcode of [image caption="Pinterest Screenshot, 30th November 2015" pin="0"]3678[/image] (note the pin="0") prevents a Pinterest Save Button from showing on that particular image. To achieve the same result without our plugin, add data-pin-nopin="true" to your image HTML. Our image shortcode supports numerous other image-level options.

BeliefMedia Plugin

Our BeliefMedia plugin provides for a means to display every image by way of shortcode (it's a seriously powerful solution that is discussed in more detail in our client area). The strength of our approach is evidenced by the way you can alter the Pinterest parameters on an image-by-image basis. For example, we add the canonical image URL to ensure you don't lose Google Image and other traffic when the image in question isn't rendered on your actual website... and you can choose to exclude specific images from being pinned.

Indiscriminately making every image pinnable on your page as our code provides is not the most efficient means of controlling the sharing that takes place. While this is the approach taken by virtually all that use the Pinterest feature, it's far from best-practice. As stated, an upcoming article deals with a more efficient means of rendering post images and controlling image attributes.

WordPress Function

The following code will add the necessary Pinterest JavaScript to your page that will automatically overlay the Pinterest Pin button on your images. They're essentially set-and-forget options that will only need to use once. However, you can come back and update them again in the future. Our shortcode is rather basic and doesn't include all available options .

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
 Add a Pinterest Save Button over Every Image in WordPress
4
 http://www.beliefmedia.com/pinterest-pins-wordpress
5
*/
6
 
7
8
 
9
  $atts = array(
10
    'data-pin-save' => 0,
11
    'data-pin-do' => 'buttonBookmark', /* buttonPin */
12
    'data-pin-hover' => 1,
13
    'data-pin-round' => 0,
14
    'data-pin-tall' => 0,
15
    'data-pin-url' => get_post_permalink($post->ID),
16
    'data-pin-color' => 0 /* white or red defaults to grey */
17
  );
18
 
19
  $colorarray = array('red','white');
20
 
21
  $return = '<script type="text/javascript" async defer';
22
  if ($atts['data-pin-save']) $return .= ' data-pin-save="false"';
23
  $return .= ' data-pin-do="' . $atts['data-pin-do'] . '"';
24
  if ($atts['data-pin-hover']) $return .= ' data-pin-hover="true"';
25
  if ($atts['data-pin-round']) $return .= ' data-pin-round="true"';
26
  if ($atts['data-pin-tall']) $return .= ' data-pin-tall="true"';
27
  if ( ($atts['data-pin-color']) && (in_array($color, $colorarray)) ) $return .= ' data-pin-color="' . $atts['data-pin-color'] . '"';
28
  $return .= ' src="//assets.pinterest.com/js/pinit.js"></script>';
29
 
30
 echo $return;
31
}
32
add_action('wp_footer', 'beliefmedia_pinterest_js_footer');

Function Attributes

You should hard-code your options into the $atts array before copying it to your custom functions file.

data-pin-save

If set to data-pin-save="1", Pinterest will return an old-style "Pin It" button (rather than the "Save" button).

data-pin-hover

Shows the Save button only when a user hovers over images (default). This applies to all images on the page. To show over all images all the time, use data-pin-hover="0".

data-pin-round

Changes the Save button to the round and red style. By default it is false. To enable, use data-pin-round="true".

data-pin-tall

Changes the height of the Save button. Rectangular buttons are twice as wide as they are tall. Rectangular buttons: true (28px for rectangular, 32px for round) or [not set] (20px for rectangular, 16px for round). The code defaults to a rectangle image overlay.

data-pin-color

No longer documented and not guaranteed to work, you can optionally try data-pin-color="white" or data-pin-color="red". It's best to leave it.

data-pin-url

The data-pin-url attribute to associate an image to a particular URL. This will guarantee that the Pin is linked to the source URL that you want. This is particularly useful for pages with multiple images that link to various places on your website. By default we'll use your page permalink. It's best to leave this option.

Considerations

  • Images need to be at least 100px by 200px to be saved to Pinterest by the Save button, and 200px by 200px to be saved using the hover button.
  • As stated, our image shortcode (that we hope to share soon) supports additional Pinterest attributes, most notably data-pin-media which permits you to curate (or automatically populate) a custom description, URL, and higher quality pinnable image.
  • Find the Pinterest documentation here .

Download


Title: Add a Pinterest Save Button over Every Image in WordPress
Description: Show a Pinterest Follow, Pin, Board, or Profile Widget in WordPress With Shortcode.
  Download • Version 0.1, 1.1K, zip, Category: WordPress Shortcodes

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment