Plugin Directory

Simple Facebook Link

Author: David Artiss

From version 1.3 you must now install the Simple URL Shortener plugin for the URL shortening to work in this plugin

The code for Simple Facebook Link should be added to the bottom of appropriate post/page templates within your theme (and in the case of posts, within "the loop").

Simple Facebook Link simply returns a URL - this URL is a link to Facebook with your post/page URL and blog title within it. It can even use TinyURL and other URL shortening services to make the link passed to Facebook even more convenient.

Here's an example.

<a href="<?php simple_facebook_link(''); ?>">Share on Facebook</a>

This will display the text "Share on Facebook" on your page/post. However, when clicked on it will take you to Facebook, where it will have your blog post/page details and will give the current user an option to add a comment before sharing it with their Facebook community.

In the case of this example, no parameters were passed and, hence, no URL shortening service was used. If, however, you'd like to use a such a service, simply add one as a parameter. A full list can be found in the documentation for the Simple URL Shortener plugin.

The following is an example of how it could be used, with a function_exists check so that it doesn't cause problems if the plugin is not active...

<?php if (function_exists('simple_facebook_link')) : ?>
<a href="<?php simple_facebook_link('is.gd'); ?>">Share on Facebook</a>
<?php endif; ?>

This also requests is.gd to be used to shorten the URL.

From version 1.3, you can also specify a second parameter (which is optional and can be omitted), allowing you to override the URL. This is useful if you wish to add a Facebook link outside of "the loop".

An example is...

<a href="<?php simple_facebook_link('is.gd','http://www.artiss.co.uk'); ?>">Share on Facebook</a>

This overrides the URL to the artiss.co.uk homepage and shortens it using the is.gd service.

Tags:

Download

FYI

Compatibility beta

Your Setup

Log in to vote.

The Consensus

No data
100,1,1

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(2 ratings)