Connect with us

Tips & Tricks

Creating a custom widget

Today let’s learn a simple quick trick on how to create a custom widget. For my example I will show you how I created my Showcase widget located in the middle, to the right of the posts.

First under your functions.php file type in the following:

<?php // Custom Widget
function MyCustomWidget() { ?>
<li class="widget">
    <h2 class="heading">Latest Showcase</h2>
        <ul>
        	<?php include(TEMPLATEPATH . '/includes/showcase.php'); ?>
        </ul>
</li>

<?php }

register_sidebar_widget('The Custom Widget for Showcase', 'MyCustomWidget'); ?>
  • Always make sure your code is between the <?php and ?> for it to work.
  • Once we call the function, the rest is assuming html code that you may or may not need.
  • For instance, you may just put in a picture and call it a day. But my code starts with <li< because my sidebar’s start and end with <ul<.
  • Any way, once your done, just set the final “register_sidebar_widget('the widget title', 'the name of the function');

That’s it! Now you have a custom widget with what ever you want!

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

Josh Groban Net Worth

Josh Groban Net Worth

Joshua Groban Joshua Winslow Groban is an American songwriter, record producer, actor, and singer. Groban was born on February 27, 1981, in LA, California. Both his parents were artistically inclined and instilled the love of music and theater in their children. Melinda, his mother was an interior designer and an artist while Joshua inherited the […]

Mike Bushell Net Worth: How Rich is Mike Bushell Actually?

Mike Bushell Net Worth: How Rich is Mike Bushell Actually?

Mike Bushell is an English sports presenter who is best known for his appearances on BBC Breakfast. He is an adventurous man who holds an incredible world record for participating in the greatest number of different sports. He achieved this feat while working for BBC One. As of 2019, Mike Bushell net worth is estimated […]

Omi In A Hellcat Net Worth: How Much is the YouTuber Worth?

Omi In A Hellcat Net Worth: How Much is the YouTuber Worth?

Omi In a Hellcat is an American YouTube personality and entrepreneur who depicts his sensational lifestyle through vlogs on his YouTube channel. As of 2019, Omi In A Hellcat net worth is estimated to be $60 million. Unfortunately, Omi’s real name is unavailable to us. He was born on August 6, 1985, in Philadelphia, United […]