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:

register_sidebar( array(
		'name' => __( 'area-name', 'twentyeleven' ),
		'id' => 'sidebar-6',
		'description' => __( 'Your Area Name' ),
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget' => "</aside>",
		'before_title' => '',
		'after_title' => '',
	) );

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.

Related posts:

  1. Quick Tip 21 – Custom Login Screens
  2. How To Speed Up Your WordPress Blogs
  3. Using wordpress template hierarchies to control CMS sites
  4. Magento: Adding an RSS Feed
  5. Adding Free Sample or Tester Products in Your Magento Shop

Leave a Reply


Contact Us Today...

If you have any questions about our services or want to arrange a free no obligation consultation contact us today or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Bit Torrent Study Discovers Most File Sharers Are Now Monitored

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

Cardiff: 02920 290 080 Bristol: 01179 000 482