Results 1 to 4 of 4

Thread: How to create Sidebars with Multiple Widgets

  1. #1
    Join Date
    Jun 2009
    Posts
    4,586

    How to create Sidebars with Multiple Widgets

    I am one of those WordPress users that love the ability to customize their front end functionality with easy to use widgets. Now what i want is to create multiple dynamic sidebars to add various combination of widgets to customize my WordPress theme even more. So i wanted help from you all guys to guide me to create Sidebars with Multiple Widgets in Wordpress. Please help me.

  2. #2
    Join Date
    Feb 2009
    Posts
    217

    Re: How to create Sidebars with Multiple Widgets

    Creating multiple widget-enabled sidebars is very similar to creating a single sidebar. Here is how:-

    Basically, your theme’s functions.php file is the file that controls whether or not your Wordpress theme is “widget enabled”. Many themes already contain this file, and many do not. So if yours does not you just need to create it. Here is what you would need to put in your functions.php file in order to make your theme “widget enabled”…
    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar();
    ?>

    Next you need to put some php code inside your sidebar.php file in order for you to actually show the widgets on your Wordpress blog. Located your Sidebar.php file and place this code in your desired location.

    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar() ) : ?>
    <?php endif; ?>
    Now your wordpress theme ( if it by chance was not already ) is widget enabled and can actually utilize the Wordpress Widget technology. That is the first step that must be covered.

    Now you have to follow the next step that is Setting up Multiple Widget Enabled Sidebars:

    Now to the good stuff. Now we want to create more of these. If you noticed, in your administration interface under Design you now have a widgets section where you can manage your widgets for your sidebar. But we need to create more of these. Here’s how we do it. Go back to your functions.php file and input the following…
    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array('name'=>'sidebar1',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    register_sidebar(array('name'=>'sidebar2',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    ?>
    You can just continue repeating this code over and over to cover however many dynamic widget sidebars that you need. Once you are done with this, next you need to input some code in your sidebar.php file to actually present these new widget sidebars that you have created. Do this…

    Sidebar1 code goes like this
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('sidebar1') ) : ?>
    <?php endif; ?>
    Sidebar2 code goes like this
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('sidebar2') ) : ?>
    <?php endif; ?>
    And on and on. You can use some simple PHP if else statements to put specific sidebars on specific pages. For example, you may want to place sidebar1 on only the homepage, and sidebar2 on the rest of the pages but not the homepage. Here’s the code I put together to accomplish this…

    <?php
    if (is_home()|| is_page()) {
    echo wpads(’adFill’);
    ( !function_exists(’dynamic_sidebar’) || !dynamic_sidebar(’sidebar1′) );
    } else {
    echo wpads(’adFill’);
    ( !function_exists(’dynamic_sidebar’) || !dynamic_sidebar(’sidebar2′) );
    echo wpads(’SADF’);
    }
    ?>
    That’s it! You now have multiple widget enabled sidebars running on your wordpress blog. This gives your site much more flexibility in design and functionality and can really enhance the content that you deliver to your visitors. Now you can go to your wordpress admin interface and you will see all your widget sidebars in a dropdown menu where you can drag and drop items to and from each specific sidebar. Source: chasesagum

  3. #3
    Join Date
    May 2008
    Posts
    2,792

    Re: How to create Sidebars with Multiple Widgets

    To create multiple sidebars, we’ll be using register_sidebars. You need to enter the code in the template of wordpress theme sites relevant wordpress widgets where you want to work.This function is similar to register_sidebar(), in that it accepts the same parameters, but it also accepts a count parameter and a name parameter. Instead of the previous code, you can use different dynamic sidebars on different areas of the template locations

  4. #4
    Join Date
    Jun 2009
    Posts
    4,586

    Re: How to create Sidebars with Multiple Widgets

    Thanks for the quick helps friends. However it looks very simple, i need to go through it carefully. Anyways, i'll be back when i'll get finished doing this. That is all i needed. I appreciate your help. Keep it up.

Similar Threads

  1. Multiple repeating Widgets in OS X Lion
    By The Picture in forum Operating Systems
    Replies: 1
    Last Post: 09-12-2011, 06:33 AM
  2. Cannot Create Multiple Calendar on iCloud?
    By Jalela in forum Technology & Internet
    Replies: 7
    Last Post: 18-06-2011, 09:24 PM
  3. how to create multiple windows
    By Chang2 in forum Operating Systems
    Replies: 3
    Last Post: 26-10-2010, 05:26 AM
  4. Create multiple partition in USB
    By InterMania in forum Operating Systems
    Replies: 3
    Last Post: 04-07-2009, 05:08 PM
  5. To create multiple websites with same domain name.
    By Japheth in forum Technology & Internet
    Replies: 3
    Last Post: 02-04-2009, 03:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,775,719.79670 seconds with 16 queries