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!

4 Comments

4 Comments

  1. Pingback: WPStart.org » Blog Archive » WordPress links week 3 - 2009

You must be logged in to post a comment Login

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

Kurt Volker Net Worth: How Rich is the US Diplomat Actually?

Kurt Volker Net Worth: How Rich is the US Diplomat Actually?

Kurt Volker is an American diplomat. He served as the U.S. Ambassador to NATO and also as executive director of the McCain Institute of International Leadership. Kurt Volker net worth is as of 2019 is estimated to be $8 million. Volker was born on December 27, 1964, in Hatboro, Pennsylvania to Benjamin and Thelma Volker. […]

Eugenio Derbez net worth​.

Eugenio Derbez net worth​.

Eugenio Derbez net worth​. Eugenio Derbez is an actor, producer, writer, and director. He holds a film directing degree from MICT (Mexican Institute of Cinematography and Theater) apart from an acting degree from Televisa acting school. The star is trained in various arts such as music, dance, and singing. He keeps prepping himself in Los […]

Alejandro Rosario Net Worth: How Rich is the Tik Tok star?

Alejandro Rosario Net Worth: How Rich is the Tik Tok star?

Alejandro Rosario is an up and coming Internet superstar who is famous for his activities on an app called Tik Tok. Within a couple of months, Rosario has been able to gain a huge following on his Tik Tok account. As of 2019, Alejandro Rosario net worth is estimated to be $100,000. Alejandro was born […]