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

powered by WassUp

Recent Posts: Fully Net Worth . com

City Girls Net Worth: 5 Interesting Facts About The Hip hop duo

City Girls Net Worth: 5 Interesting Facts About The Hip hop duo

City Girls is an American hip hop duo originally from Miami which consists of the rappers Caresha Romeka Brownlee (known as Yung Miami) and Jatavia Shakara Johnson (known as JT). Here are some facts about City Girls including their net worth, career and many more. 1. City Girls has an estimated net worth of $500,000 […]

Tasha K Net Worth: How Rich is the YouTube star Actually?

Tasha K Net Worth: How Rich is the YouTube star Actually?

Tasha K is an American social media personality and pop culture aficionado. She is best known for her YouTube channel ‘unWinewithTashaK’. Tasha K net worth is under review and is not available at the moment. Tasha whose real name is Latasha Transrina Kebe was born on March 10, 1982, in Panama City, Florida but later […]

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp is an English radio host and presenter. He presents for the national radio network Capital FM and is part of the nineteenth series of I’m a Celebrity…Get Me Out of Here!. As of 2019, Roman Kemp net worth is estimated to be £2 million. Kemp was born on 28 January 1993, in Los […]

%d bloggers like this: