RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.38% (6.14%*) • Home Loan Fixed: 5.44% (6.26%*) • Fixed: 5.44% (6.26%*) • Variable: 5.38% (6.14%*) • Investment IO: 5.69% (6.52%*) • Investment PI: 5.49% (5.98%*)

Display The Facebook Save Button With WordPress Shortcode (or PHP)

Display The Facebook Save Button With WordPress Shortcode (or PHP)

From Facebook, "the Save button lets people save items or services to a private list on Facebook, share it with friends, and receive relevant notifications. For example, a person can save an item of clothing, trip, or link that they're thinking about and go back to that list for future consumption, or get notified when that item or trip has a promotional deal".

Pages saved to Facebook via a website save button may later be shared on the platform. In its most basic form, the save button acts like a social bookmark. If you're in the 'business of business', having the save button continues to work for your conversion by reminding users of saved pages.

Saves can be removed from within Facebook or your website.

The Result

The button above shows a small button aligned to the left ([fbsave align="left" size="small"]). By default, the code will return a large button centered as follows (using [fbsave]):

When our shortcode is used, the current page is returned by default, although another page can be referenced. Attributes are listed below.

Shortcode Attributes

The following shortcode are available to alter the save button's behaviour.

url

The current page is returned by default. To use another page, use [fbsave url="http://www.beliefmedia.com/"].

size

Two sizes are available: small and large. Use as follows: [fbsave size="small"].

align

By default the button will center in paragraph tags. To align left or right, use [fbsave align="left"] (CSS applies as per below).

padding

The padding applies to the button when aligned left or right only (defaults to 8px 15px; 8px 15px. To change the default behaviour, alter the shortcode function, or use the following in your shortcode: [fbsave padding="5px 10px 5px 10px"].

Shortcode Function

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

It's a requirement when using this function that you download the FBSDK function. Review its use and download the code here. It's possible that your theme is already rendering the SDK by default (open up your source code and search for "connect.facebook.net" to confirm).

1
<?php 
2
/*
3
 Embed Facebook Save Button with WordPress Shortcode (or with PHP)
4
 http://www.beliefmedia.com/facebook-save-button-wordpress
5
 Requires Facebook SDK: http://www.beliefmedia.com/facebook-sdk-wordpress
6
*/
7
 
8
9
  extract(shortcode_atts(array(
10
    'url' => false, /* Defaults to current WP page */
11
    'size' => 'large', /* small, large */
12
    'align' => false,
13
    'padding' => '8px 15px 8px 15px',
14
  ), $atts));
15
 
16
  /* Current page or defined URL? */
17
  $url = ($url !== false) ? $url : get_permalink();
18
 
19
  /* Formatting */
20
  $css = ($align !== false) ? 'float: ' . $align . '; padding:' . $padding : 'text-align:center;';
21
  $return = '<div style=&quot;' . $css . '&quot;><div class=&quot;fb-save&quot; data-uri=&quot;' . $url . '&quot; data-size=&quot;' . $size . '&quot;></div><div style=&quot;clear: both;&quot;></div></div>';
22
 
23
 /* Result */
24
 return ($align === false) ? '<p>' . $return . '</p>' : $return;
25
}
26
add_shortcode('fbsave','beliefmedia_facebook_save_button');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

PHP Function

The following function may be used outside of WordPress. Again, the SDK is required.

1
<?php 
2
/*
3
 Embed Facebook Save Button with WordPress Shortcode (or with PHP)
4
 http://www.beliefmedia.com/facebook-save-button-wordpress
5
 Requires Facebook SDK: http://www.beliefmedia.com/facebook-sdk-wordpress
6
*/
7
 
8
function beliefmedia_facebook_save_button($args = '') {
9
 
10
  $atts = array(
11
    'url' => false, /* Defaults to current WP page */
12
    'size' => 'large', /* small, large */
13
    'align' => false,
14
    'padding' => '8px 15px 8px 15px',
15
  );
16
 
17
  /* Merge $args with $atts */
18
  $atts = (empty($args)) ? $atts : array_merge($atts, $args);
19
 
20
  /* Current page or defined URL? */
21
  $url = ($atts['url'] !== false) ? $url : $actual_link = (isset($_SERVER['HTTPS']) ? &quot;https&quot; : &quot;http&quot;) . &quot;://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]&quot;;
22
 
23
  /* Formatting */
24
  $css = ($atts['align'] !== false) ? 'float: ' . $atts['align'] . '; padding:' . $atts['padding'] : 'text-align:center;';
25
  $return = '<div style=&quot;' . $css . '&quot;><div class=&quot;fb-save&quot; data-uri=&quot;' . $url . '&quot; data-size=&quot;' . $atts['size'] . '&quot;></div><div style=&quot;clear: both;&quot;></div></div>';
26
 
27
 /* Result */
28
 return ($atts['align'] === false) ? '<p>' . $return . '</p>' : $return;
29
}
30
 
31
/* Basic Usage */
32
33
 
34
/* Usage with $args */
35
$args = array('align' => 'left', 'size' => 'small');
36
37
?>

The $args array keys of url, size, align, and padding are merged into the resulting $atts array.

Considerations

  • If you're a business and require that the SAVE button be integrated with your product catalogue, get in touch with us. It's somewhat of a necessity for any e-commerce presence to build these Facebook features into your website as a means to supplement your advertising and marketing strategies.
  • All saved links will be added to the Saved view, which can be found at www.facebook.com/saved or for mobile apps via navigating to More -> Saved.

Download


Title: Display Facebook Save Button (WP Plugin)
Description: Display Facebook Save Button with WordPress Shortcode (or with PHP).
  Download • Version 0.1, 1.6K, zip, Category: WordPress Plugins (General)
WordPress Shortcodes, (714.0B)    PHP Code & Snippets, (1.1K)    

■ ■ ■

 
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