Anything and everything to do with technology
6 Nov
I’ve finally taken the plunge into learning how Wordpress development works. I don’t claim to be an expert, but the following information might be useful to someone with very little programming experience but the desire to add a new social media widget to their blog site.
First off, I download the Social Media Page plugin from Philip Norton, found on the Wordpress Plugin Directory. The installation instructions are fairly straight forward, so I won’t reiterate them here. Basically, after the install, you enable the plugin and go add your social media site login names. Doing so will store the entries in a new database table that was created when you initialized the plugin.
I realized that plugin was only build to display your links on a new page, and I wanted to instead display them in the sidebar as you now see over there on the side of the page. To accomplish this, open the social-media-page.php file and insert the following lines toward the bottom of the file:
/* Widget section added by Brian Richmond – 4Minds Internet Group
Replace the existing social-media-page.php to get widget functionality in your blog site
*/
function widget_social_media() {
?>
<h2 class=”widgettitle”>Social Media</h2>
<?php echo smpCreatePage(); ?>
<?php
}function init_social_media() {
register_sidebar_widget(__(’Social Media’), ‘widget_social_media’);
}add_action(”plugins_loaded”, “init_social_media”);
This code will register a new sidebar widget that you can add using the Wordpress administrator. Once you upload the new file to your server, the widget should be immediately available to add to your site. If you have configured your usernames in the Social Media Page properties, the links will show up immediately on the page.
Note that I’ve slightly modified the code inside of the smpCreatePage() function to result in the output that I wanted to see on my site. Feel free to play around with the output to match your own needs. Let me know if you’ve found this tutorial useful.
5 Responses for "Wordpress Widgets 101: Social Media Links"
Wow, even I’m starting to “get it”. Thanks a ton for this post. I’ve been struggling with widgets for awhile. I think, thanks to your post, the light is finally starting to blink.
Thanks for the Notepad headsup too. Looks much improved over the last time I tried it.
I can’t take full credit. I had help from other sites, but this does provide a useful stepping stone to diving into Wordpress development. One thing I learned while working on this was that the widget code needs to be part of an existing plugin. I might find out otherwise as I try other things, and I’ll let everyone know what I find out.
[...] Media Widget Update Nov.07, 2008 in Uncategorized This is a follow-up to yesterday’s post on building a sidebar widget for the “Social Media Page” plugin from Philip Norton. [...]
Hi! I don’t know why but it gave me a fatal error when I added the code to the bottom of the file…?
Stephanie, did you download the Social Media Page plugin that I linked to in the article? In my code, the call to “smpCreatePage” is directly linked to that plugin, otherwise you may get this error.
Also, looking back at my code here, I realize that it’s only partially there. I uploaded the full widget file for download here: http://blog.4minds.com/?attachment_id=338
Let me know if you still have issues. Send me your blog link and I’ll take a look as best I can. Good luck!
Leave a reply