WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] New custom widget area

[Resolved] New custom widget area

  • 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

    thanks you mean replace the header code with above?

    I tried this

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

    the whole site went white!!!

    Moderator Michael

    @alchymyth

    Forum Moderator

    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');

    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.

    ok now widget area not displaying anything at all

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

    yes its static

    then use is_front_page() instead of is_home()

    it worked
    thanks a lot 🙂

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