With its over 200 millions registered users (read 200 Million Strong) Facebook can bring a lot of traffic to your blog, so in my opinion it’s very important to add a “Share on Facebook” button to your blog.
If you noticed, Facebook as a sharer url allowing you to share a link.
I am going to use this feature to create the button.
sharer.php needs two variables to share your page:
u for the link and
t for the title, so we need to create a link like
The function that returns URL for the permalink to the post currently being processed is
the_permalink(). You can read more information about it at the official page.
The function to get the title is (guess what?)
the_title. More information at the official page.
Just in case you are looking for some interesting Facebook icons, I am giving you a couple of links:
http://www.webfruits.it/dblog/articolo.asp?articolo=62 (this one is in italian, just go on download button at the end of the page).
If you know more links about free Facebook icons, just let me know and I’ll add them here.
Time to write some code now… in your
wp-content/themes/ folder of your WP installation, locate the folder of your theme and check for
Warning: not all themes have a single.php file… if you can’t find it, then probably the right file to edit is index.php… anyway it could be the right file if you see
The code I suggest you to add, after
And you’ll have your Facebook link like the one I added on my blog.