Create your own Widget in WordPress

During one of ma projects this week at Archmage I had to come up with a site to post articles dynamically and they needed to be reviewed and edited then and there where it is required. Since we have already passed the deadline (due to this n this n that…) and already into extended time I was thinking for an alternative solution And found WordPress will be more than handier tool for our particular task. Since everyone else at the office were also sharing the same idea at this point, we decided to work on it using Worpress.

But then again I had to run into another problem with wordpress, since this is just a part of the vast system that we are developing, it required some of it’s other components to be included within the page. Well again I’m into a crunch situation, this time around I came to a conclusion, in order to overcome this senario, I’m gonna devolop ma own widget in wordpress but still I was wondering wether it will be a possibility, but thanks to my friend Niro (A pro in PHP) who insisted me that it should a possibility, I could come up with the solution.

In your wordpress control panel select Edit Theme button which is located under the Presentation tab yours. Then you will get all the php files and stylesheets of your currently selected theme.

Now you can click on sidebar.php and start developing your own widget.

Below I give you a piece of code which will create a very simple widget for you, the code looks as follows,

<!–start of widget//–>
<h2><?php _e(‘My Widget Title’); ?></h2>
<ul>
<li>
<?php _e(“My Widget Content”); ?>
</li>
</ul>
<!–End of widget//–>

Above code will create a menu with title “My Widget Title” & a list item “My Widget Content” in each & every page of your WordPress blog.

The idea behind this was very simple still i believe one can do wonders with this in WordPress.

Advertisements

2 thoughts on “Create your own Widget in WordPress

Comments are closed.