Social Media Share Buttons For Twitter Facebook post shows you how to display the social sharing buttons for Facebook and Twitter in post and more.
Last Updated: June 24, 2019
Latest News: I updated the information below.
The plugin that I will be using is from Tips And Tricks HQ. They have released a very simple and effective Social Sharing Plugin that uses very little resources.
The code and information is obtained from codex.wordpress.org.
What You Need:
- Fat Free WordPress Social Share Buttons Plugin
- Page from wordpress.org Conditional_Tags#The_Front_Page (Optional to read)
Social Media Share Buttons For Twitter Facebook
The plugin will display Twitter and Facebook on your blog post. What if you want to add and modify the code so that it displays on pages, blog post, front page or other places?
Step 1 ) Install the plugin as you normally install a plugin in WordPress. The plugin has no settings to configure. So it is a simple installation and activation process.
Step 2 ) FTP into your server and locate your plugins directory. Find the following plugin folder gfts-share-buttons. Locate inside the following file gfts_share_buttons.php and download it locally via FTP.
Note: If you don’t want to FTP into your server for what ever reason. You can always edit the file from your website. Log in as admin and click on the following Plugins -> Editor. Locate and edit the plugin file. Make sure you save your settings.
Step 3 ) Open the file using a text editor or a php editor. Locate the following if(is_single()) and replace it with the following code. See image below.
Understanding The Code
What it all means:
The following if (is_single()) //Load these in the single post view only. This is a very simple explanation.
New code to add if (is_single() || is_front_page ()) in the two locations as shown below. This will display the social media buttons on a single post and also on the front page as well.
Important: Once you finish editing your file, save and upload the file to the same location on your server.
The code above is to prevent the social media buttons from appearing on all pages like your Contact Us page.
What if you want it to appear on certain pages?
A Single Post Page
is_page( ’17’ ) //When Page 17 is being displayed.
is_single( ‘Irish Stew’ ) //When the Post with Title “Irish Stew” is being displayed as a single Post.
From the above code you can see how easy it is to display the social media buttons on certain pages. Search for all the pages where you would like the social media buttons to appear and add them as you see in the example above.
If you wanted to display the buttons on more than one page then you would use the following code.
is_page( array( 17, 19, 1, 11 ) )
(Note: Remember that your pages ID number will be different )
Step 4 ) The following image displays the social buttons on a page or post.
If you need to find how to add different functions, click on the following URL Function Reference from wordpress.org.
That is how simple it is to modify the code in this great little plugin. I will be updating this post from time to time. If you have any questions please let me know.