I recently ne to create a Facebook “Like” box for my girlfriend as a WordPress widget. Of course, this can easily be creat using the WordPress text widget. However, the girlfriend is new to WordPress , has no idea about coding, and to make matters worse, she only want it to appear on the article and category pages! So I decid I’d better quickly create a custom WordPress widget that would be flexible enough for her nes.
If you’re familiar with WordPress, you’ll also be familiar with its draggable widgets, so you can place them in, say, a sidebar or any “widgetiz” area like headers or footers. It’s one of the many powerful features of WordPress that lets you add all sorts of your own “stuffing” as you go along.
FB_widget_sanwebe
How to start?
You can create your own standalone Widget Plugin that can be install and activat on your plugin admin page, but like many people, I prefer to have my widget code in the default theme’s functions.php file , which is locat in your active THEME). When arrang like this, our custom widget will work perfectly and there is no ne to install an additional plugin.
We will write the code of the basic widget
Open your theme’s function.php file (create one if you can’t find one), and copy and paste this PHP code anywhere in function.php and save the file. Then go back to your admin widget page, where you should see the Facebook Likebox widget in the Available widgets section. Simply drag it to the sidebar to see it in action.
As you can see, everything goes smoothly, the Facebook “Like” box appears as request, but it is quite static. It has no user option in the admin page, nor can it be flexibly customiz by the user. If we ne to change anything, we have to explicitly change the code in the function.php file. So in order to add more philippines phone number data functionality to our facebook like box widget , we ne to be very clear about how our code works. If you look carefully at the code above, you’ll notice that I’ve achiev the widget’s current functionality by following a few simple steps.
I deriv the class from the standard WP_Widget class , see the beginning of the code above.
__construct() function : defines including keywords that potential buyers can the name of the widget and its description in your widget class.
widget() function : output the HTML content for your widget.
Form() function : HTML options bw lists for users in the admin section.
update() function : This function will save the options suppli.