Adding a custom widget area in WordPress

I am currently developing a CMS website for one of our clients. My aim is to make every element of their site editable for them, meaning they can amend any element on any given page.

In most typical CMS sites there is a sidebar that contains elements like ‘Latest posts’, ‘Categories’ and a search box etc. I wanted to take it a step further and give the client full access to the sidebar and allow them to add any elements that they so wished.

A great way of doing this is by adding an area on the page where widgets can be added.

Firstly, you need to register the new widget area by adding the following code to your functions.php file:

In the ‘name’ brackets you will need to add a unique name which should be lowercase, you will also need to add a description. What you use as your description will be the name of the Widget area within WordPress. From the WordPress admin area you can drag across the widgets that you wish to have into your new widget area. You also need to make sure that the ‘id’ is a unique number and not already in use.

You then need to create the DIV on your page for the widget area to display in. To then call the widget area on your page use the following code:

if ( ! dynamic_sidebar( 'Construction' ) ) :

You can now add or remove widgets from the newly created area as you please.

Posted By: Nish

Hi,
I'm Nish, A Web Designer for Web Design GM and really hope you find my existing and upcoming articles useful. Please leave comments below and I will try to respond to any questions as soon as possible.

Ever heard of torrents or used Bit Torrent to download movies, music or shared files over the internet? Researchers have discovered that anyone who does use Bit Torrent to download files over the World Wide Web will most probably be monitored. Studies were carried out by Birmingham University and they have discovered that if someone [...]» more