Support » Themes and Templates » More Than One Sidebar ?

  • is it possible to have more than one sidebar in wordpress ?

    what i’m trying to do is use WP as a portal of sorts where users / guest would enter into

    user would see one sidebar and guest would see another and I could post in either or

    is this possible ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • So you’re just looking to alternate between one sidebar and another on your blog, depending on user status? An easy way to do this is to verify if the global variable $user_login has a value, and perform an if/else to display one or the other version.

    So just before your sidebar elements for users, place:

    global $user_login;
    if ($user_login) :

    After that, but before the non-user (and admin) sidebar elements:

    <?php elseif(!$user_login || 'admin' == $user_login) : ?>

    (Change 'admin' to your login name, if necessary) Then to close it all up:

    <?php endif; ?>

    was just curious, did your advice mean to add both sidebar items on one sidebar page ?

    then use the code to filter user based on userlevel ?

    or would i have to have 2 separate sidebar pages pages to do this

    That’s up to you, since either works.

    I assumed in the code above use in a single sidebar template that segments the various elements in it using the code above; but you can certainly create two templates for each sidebar type, and use the if statement in *primary* templates (such as index.php) to include the correct one, depending on what’s true. The former is good for keeping it all in one place (and sticking with WordPress’ built-in templating functionality), the latter for logically separating sidebar content in their own templates.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘More Than One Sidebar ?’ is closed to new replies.