WordPress.org

Ready to get started?Download WordPress

Forums

Two Different Sidebars? (13 posts)

  1. chaseman
    Member
    Posted 3 years ago #

    I'm working on a WordPress theme,

    and I wanted to ask is it possible to have two different sidebars, one for the start page and one for the blog page? In a way so the user can add a different constellation of widgets to the sidebar?

  2. kgagne
    Member
    Posted 3 years ago #

    I've seen this functionality in other themes, such as WooThemes. Not sure how to implement it, though. Good luck!

  3. jonbyrd
    Member
    Posted 3 years ago #

    Actually I wouldn't worry about downloading a new theme. The "Total Widget Control" plugin is exactly designed to do what you are looking for.

    You'll be able to have a different array of widgets on every page, using only a single sidebar.

  4. If you're writing your own theme, you can define the sidebar areas via function calls. If you're just editing a theme, you can use "Widget Logic" to call different widgets based on certain parameters.

  5. kgagne
    Member
    Posted 3 years ago #

    @jonbyrd: that plugin no longer seems available:

    http://wordpress.org/extend/plugins/total-widget-control/

  6. chaseman
    Member
    Posted 3 years ago #

    Ipstenu,

    how would the user tell in the admin panel, to which sidebar he's adding the widgets?

  7. how would the user tell in the admin panel, to which sidebar he's adding the widgets?

    Depends on your theme a bit.

    If your theme has multiple sidebar areas (like Twenty Ten does), then you see a list of areas like this:

    • Primary Widget Area
    • Secondary Widget Area
    • First Footer Widget Area
    • Second Footer Widget Area
    • Third Footer Widget Area
    • Fourth Footer Widget Area

    In each one, you pull the widget you want in the area you want. Via widget logic (for example) you then edit the 'Widget logic' bit in the widget itself and say 'is_front' or whatever you want.

    There's also a plugin called 'Dynamic Widgets' that can do that kind of management.

    Now if you're asking 'How do I MAKE those widget areas in my theme' that's a different question! :D I wasn't quite sure what you meant, though.

  8. Rachel Baker
    Member
    Posted 3 years ago #

    My favorite way of having multiple sidebars is to use the Custom Sidebars plug-in: http://wordpress.org/extend/plugins/custom-sidebars/

    OR

    Follow the office WordPress method for adding sidebars to a theme: http://codex.wordpress.org/Customizing_Your_Sidebar#New_way_of_adding_sidebars

  9. chaseman
    Member
    Posted 3 years ago #

    Ipstenu,

    to clear the confusion up, when I said in my first post "I'm working on a WordPress theme" I meant that I'm developing one, as in creating one myself so I can put it on market places.

    It's nice a idea that there are already widgets for these type of things available, though I think I may not be able to bundle them with the theme, so I'd have to create my own functions. I may be able to do that, though I'm not quite sure how to implement that into the admin panel, so the user knows to which bar he's adding the widget.

  10. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    to clear the confusion up, when I said in my first post "I'm working on a WordPress theme" I meant that I'm developing one, as in creating one myself so I can put it on market places.

    If you're developing your own Theme, simply register however many sidebars you want, and then wrap appropriate conditionals around your calls to dynamic_sidebar().

    For example, in functions.php:

    register_sidebar(array( // Blog widget area
    'name'=>'sidebar-blog',
    'description' => 'Widget area for the blog.',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<div class="title widgettitle">',
    'after_title' => '</div>',
    ));
    register_sidebar(array( // Front Page widget area
    'name'=>'sidebar-front-page',
    'description' => 'Widget area for the Front Page.',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<div class="title">',
    'after_title' => '</div>',
    ));

    Then, in sidebar.php:

    if ( is_front_page() && ! dynamic_sidebar( 'sidebar-front-page' ) ) {
       // This will output the Front Page Widget area
    } elseif ( is_home() && ! dynamic_sidebar( 'sidebar-blog' ) ) {
       // This will output the Blog Widget area
    }

    (Note: use whatever conditionals are appropriate for your use case. This is just an example.)

  11. vaa
    Member
    Posted 3 years ago #

    thanks Chip, its working. Its just my new dynamic sidebar, after displaying all it's widgets displays also the content of the default sidebar.

    here is my code:
    [84 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    So my single pages display sidebar-front-page and then Sidebar,and I want only sidebar-front-page to be displayed.

    Thanks in advance for your respond.

  12. pzuritaona
    Member
    Posted 2 years ago #

    Dear VAA,

    It sounds that you figure out exactly what I'm looking for; unfortunately, I' m not sabby at all about how to do these things. Would you be so kind to send me an e-mail at [email address removed] so we can talk. I've been desperately trying to do this but all insructions & references from wp are just too cumbersome and leaves me in a place of hopelessness.
    Please please contact me so I can do what you just did; it looks like that dynamic sidebar is the addition to wordpress. Thanks, Patricia

  13. esmi
    Forum Moderator
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic