web hosting
build a website

Creating a sidebar in WordPress

Feb 9, 2014   //   by Anthony Devine   //   Website Development tips  //  No Comments

You may want create a new section on the side of your WordPress site or you may want a new area on your homepage where you can drop in an image of a link.

An easy way to achieve this is to register a sidebar. Firstly open up your functions.php file adn do a search for register_sidebar you will see something like:

register_sidebar( array(
		'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ),
		'id' => 'top-page-content',
		'description' => __( 'Appears at the top of each page', 'twentytwelve' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget' => '</aside>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
The above is one that I have created, you give your new sidebar a name, and id to call it, a description and you can add tags around the title in the example above a h3 tage has been wrapped around it.

Once you have added in your new sidebar save the file. Then if you go into widgets you will see your new sidebar appear, you can add widgets into this sidebar however as you have not said where you want the sidebar to appear in your template these widgets will not yet appear.

You now need to add in the following code into your template where you want your sidebar to appear:
<?php dynamic_sidebar( 'top-page-content' ); ?>
Once this is saved your widgets will show on the page.

Buckets are an alternative to widgets. Basically it allows you to do the same thing as sidebar Widgets but it is a bit more user friendly as it is a plugin. Download it here >>