1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 5.00 out of 5)

How to add a widget in WordPress

So you want to know how to add a widget in WordPress?  Well lets get right into it:

Step #1 Find you functions.php file in your WordPress theme and look for this code

Tip: Click on images to make them larger. If you find anything wrong on this page or need further assistance please comment below or contact me. 🙂
register_sidebar( array(

you will find several lines of code look for this

) );

edits

Subscribe To My YouTube Channel:

at the end of it and add the following make sure you leave the last “}” because you will need that:

	register_sidebar( array(

		'name' => __( 'maximus-great-widget' ),

		'id' => 'header-widget',

		'description' => __( 'An optional widget area for your site header' ),

		'before_widget' => '<div id="the-maximus-widget">',

                'after_widget' => "</div>",

		'before_title' => '<div id="the-maximus-widget-title">',

                'after_title' => '</div>',

	) );

You want to give the widget a name you can see the name of this widget is maximus-great-widget.
 
Notice we gave it an id called header-widget
 
Notice we gave the widget a div tag called the-maximus-widget and then we closed the tag with the after_widget code with a closing div tag.
 
Notice that we gave the widget a title div tag as well called the-maximus-widget-title
 
You can change all these names but make sure that you remember what you named them.
 


 
Step #2 Now we can add the code to where we want the contents of the widget to appear. I want it to appear in the header of the theme that I am editing so I will put it in my header.php file in my theme.
 

 <?php if ( ! dynamic_sidebar( 'maximus-great-widget' ) ); ?>

 


 
If you want to say updated on more WordPress tutorials and more subscribe to my feed and we will email them to you as we post them.

Enter your email address:

Delivered by FeedBurner

 
 

How to add a widget in WordPress was last modified: October 14th, 2013 by Maximus Mccullough

Please like, share and subscribe.

Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips

Tips

Cool People Share:
using wordpress shortcodes everywhere

1 Comment

  • Ideddyshept says:

    I discovered your blog web-site on google and check several of your early posts. Continue to maintain up the fairly beneficial operate. I just extra up your RSS feed to my MSN News Reader. Looking for forward to reading alot more from you later on!

    michael kros

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.