Sunday, July 12th, 2009 
 Author: Jon B

Adding Social Media Icons On Certain Posts

social-mediaThere are many WordPress plugins out there that allow you to display various social media buttons on your posts making it very simple for your readers to share and submit your article to various social media websites.

While this is a great way to promote your blog posts, the buttons do not serve a purpose if you simply have an announcement to make on a post.

It would be great if we can turn the option on and off as needed, right?. Well by using WordPress’ custom fields and a little bit of PHP coding, we can display or not display these social media icons.

Let’s get to it

Step 1 – Download the SexyBookmarks plugin, upload it into your plugins folder and activate it.

Step 2 – Go into the plugin settings and modify the settings. You can reorder the icons by clicking and dragging. Check mark the ones you want to display.

social1

In the Placement option, select Manually Insert.

social2

Step 3 – Go into your Themes folder and find single.php. Open the file and locate The following code:

1
<?php the_title(); ?>

The above code displays the title of your blog post. If you want the social media icons to appear right above title, then copy the code below and place it before the title.

1
2
3
<?php if(get_post_meta($post->ID, "socialmedia", true)){ 
     if(function_exists('selfserv_sexy')) { selfserv_sexy(); }
} ?>

If you want the plugin to display at the bottom of your post, then paste the above code right after:

1
<?php the_content(); ?>

Step 4 – In the Admin panel, open up one of your posts or create a new one. Scroll down to the Custom Fields section, click Enter New, name it socialmedia and give it a value of 1 or yes or whatever value you prefer, it really doesn’t matter as long as you input a value in there. Click the Add Custom field button to save it. You should now see a custom field called social media with a value of 1 or whatever value you chose.

social3

From now on whenever you want to display your social media icons, simply scroll down to the Custom Fields section, click on the name drop-down, select socialmedia and give it any value.

social4

Trackback: Trackback-URL | Comments Feed: RSS 2.0
Category: How To, Web Development, WordPress

You can leave a response.

 

  1. I am really grateful that I determined this particular article. This’s just the advice I had been looking for.

  2. Sexy Bookmarks is the best Bookmarks plugin for wordpress, I use it for all of my sites. Thanks for showing how to add the buttons manually. Till now I only used the automatic option

  3. here is momething happened here

  4. Brilliant. Excellent. Amazing.. Now adding up all buttons.

  5. Thanks! I’ve been looking for a way to turn these buttons off.

  1. [...] Red SimpleScheme Mag – themes.iwebnet.org 07/13/2009 This post was submitted by cmba138G. Adding Social Media Icons On Certain Posts – jbwebdev.com 07/13/2009 There are many WordPress plugins out there that allow you [...]

Leave a Reply






Copyright © 2010 | Theme By JBWEBDEV | All Rights Reserved