• Resolved fz11

    (@fz11)


    Hello
    I have created a new custom widget area next to a front page slider. i am using a image widget to upload an image.

    the issue I have is the new widget area is displayed in all other pages as well even when I switch to full width which normally should not display. how do I get it just to display on the front/home page.

    this is what I’ve done:

    register_sidebar(array(
    ‘name’ => __(‘Top Bar’),
    ‘id’ => ‘topbar’,
    ‘description’ => __(‘The widgetized top bar. Drag and drop widgets from the left’),
    ‘before_widget’ => ‘<div id=”%1$s” class=”widgets”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,
    ));

    and header php:

    <?php /* Widgetized sidebar */
    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Top Bar’) ) : ?><?php endif; ?>
    </div>

    is there anything I can do without too much complications?

Viewing 12 replies - 1 through 12 (of 12 total)
  • if ( is_home() ) dynamic_sidebar('Top Bar');

    check if it’s the homepage with is_home() you don’t need the function_exists part anymore

    Thread Starter fz11

    (@fz11)

    thanks you mean replace the header code with above?

    Thread Starter fz11

    (@fz11)

    I tried this

    <?php /* Widgetized sidebar */
    if ( is_home() )(‘dynamic_sidebar’) || !dynamic_sidebar(‘Top Bar’) ) : ?><?php endif; ?>
    </div>

    the whole site went white!!!

    thanks you mean replace the header code with above?

    more-or-less yes;

    replace:

    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Top Bar') ) : ?><?php endif; ?>

    with:

    if ( is_home() ) dynamic_sidebar('Top Bar');

    Thread Starter fz11

    (@fz11)

    I tired this and went all white again

    used this
    <?php if ( is_home() ) dynamic_sidebar(‘Top Bar’);
    <?php endif; ?>

    instead of

    <?php /* Widgetized sidebar */
    if ( is_home() )(‘dynamic_sidebar’) || !dynamic_sidebar(‘Top Bar’) ) : ?><?php endif; ?>
    </div>

    … remove the <?php endif; ?> part

    <?php if ( is_home() ) dynamic_sidebar('Top Bar'); ?>

    .. that’s all.

    Thread Starter fz11

    (@fz11)

    ok now widget area not displaying anything at all

    Are you using a static page as your front page in the settings -> reading?

    Thread Starter fz11

    (@fz11)

    yes its static

    then use is_front_page() instead of is_home()

    Thread Starter fz11

    (@fz11)

    it worked
    thanks a lot 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘New custom widget area’ is closed to new replies.