Filing Cabinet - woman putting back an importa...

You are familiar with the wordpress Widgets section. You can drag and drop things to your sidebar: recent posts, latest posts. It is a good wordpress feature.

What about if you want to edit stuff on other locations of your website directly from the admin panel ? For example a portion of your header or footer, or you just simply want to add another sidebar.

It is simple, in the template file you want to add a section where you will drag and drop widgets, use the following code:

<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘sidebar1′) ) : ?>
<?php endif; ?>

You’re not done yet. Now you have to register the sidebar.  We called the sidebar “sidebar1″.

Open functions.php file and then paste the following code:

if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘name’=>’sidebar1′,
‘before_widget’ => ‘<li id=”%1$s” class=”sidebaritem”>’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h2 class=”widgettitle”>’,
‘after_title’ => ‘</h2>’,
));

Now you’re done. It is still called sidebar, but you can use it on your header, footer or homepage.

Lucian Apostol

Lucian Apostol is the owner of Flame Scorpion, he is a Web developer for 7 years and his mission is to share with you what he knows.

Website - More Posts

Related posts:

  1. How to add widgets to your theme without hiding the current ones
  2. Customize your sidebar: show different things on sidebar
  3. How to directly edit WordPress themes
  4. How to show posts from a specific category anywhere on your website
  5. Why I decided to move all my websites to WordPress