WordPress.org

Forums

[resolved] Sidebar widgets only work with a typo?! (3 posts)

  1. pau1w
    Member
    Posted 4 years ago #

    I have a very strange problem with a theme I'm currently developing - I registered some widget-ready areas and they all work fine, but then I realised I'd made a typo..

    <?php if ( function_exists('dynamic_<strong>sider</strong>bar') || dynamic_sidebar('Footer Area 1') ) : else : ?>

    I'd typed 'dynamic_siderbar', obviously instead of 'dynamic_sidebar'.

    But when I correct this typo, the widgets no longer work. I've tried registering them completely from scratch but they still only work with the typo.

    I'm gonna be selling this theme, as well, so I'd really like the damn things to work properly so there's no problems for other people.

    Any ideas?

    Cheers,
    Paul.

  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    'normally' the if statement is in the negated form:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
    static code here
    <?php endif; ?>

    in your case, I would try and make the if statement with && (AND) :

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Footer Area 1') ) : else : ?>
    static code here
    <?php endif; ?>

    ps:
    looking into the sidebar code of Twenty Ten, it can probably be safe to assume that one does not need to check the existance of function_exists('dynamic_sidebar') anymore with wp3.

  3. pau1w
    Member
    Posted 4 years ago #

    That worked. Much appreciated, mate.

Topic Closed

This topic has been closed to new replies.

About this Topic