WordPress.org

Ready to get started?Download WordPress

Forums

conditional sidebar (7 posts)

  1. staceyzav
    Member
    Posted 1 year ago #

    Hi -

    I have the following PHP statement that adds a sidebar (named page-header) to my site, except I want to modify it so that it EXCLUDES this particular sidebar from the homepage. Can anyone help modify to make the sidebar NOT show up on the home page? Thanks!

    <?php /* Widgetized sidebar */
        if  (!function_exists('dynamic_sidebar') || !dynamic_sidebar('page-header') ) : ?><?php endif; ?>
  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    try a diff name for 'page-header'.

  3. staceyzav
    Member
    Posted 1 year ago #

    OK, thanks - but it was working even with that name (but I guess that is a bad idea for a name), I just don't want it to show up on the homepage. I need to add something like: if ( !is_home() ) somewhere, just not sure where to add it.

    so if I change the name of the sidebar to topbar - where can I add my conditional statement to get it to not appear on the home page.

    <?php /* Widgetized sidebar */
        if  (!function_exists('dynamic_sidebar') || !dynamic_sidebar('topbar') ) : ?><?php endif; ?>

    Thanks!

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    Above is not a full Page Template, please use Pastebin or if short (less than a 1000000000000000000 lines - kidding! less than 10?) post your full Page Template.

  5. staceyzav
    Member
    Posted 1 year ago #

    Unfortunately, I don't have the full page template. I'm using Genesis framework to build my theme, so I'm just adding a "simple hook" through the wp dashboard so I can add an additional sidebar to every page except the homepage. The statement above is a good start as does what I want it to do (adds a sidebar), except I'm trying to figure out how to exclude it from the homepage.

    So basically I'm just looking for a conditional statement that says the following:

    • add sidebar (named topbar) unless you are on the homepage

    Does that help!?

    Thanks for your help either way!

  6. alchymyth
    Forum Moderator
    Posted 1 year ago #

    EXCLUDES this particular sidebar from the homepage

    try using a conditional tag http://codex.wordpress.org/Conditional_Tags

    either is_home() or is_front_page():

    example to replace your code (untested):

    <?php /* Widgetized sidebar */
        if ( !is_home() ) dynamic_sidebar('topbar'); ?>

    for specifics, please contact the theme's developer.

  7. staceyzav
    Member
    Posted 1 year ago #

    That works perfectly - thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.