• Hi all,

    Apologies in advance if this is a silly question. (Relative developer n00b.)

    I’m working with a client’s custom plugin on a site. How it works is, you drag a widget that the plugin creates into its own custom sidebar. Then, on a page-by-page basis, you can enable this sidebar or disable it. What I’m trying to do is, if the page has the sidebar enabled, show that ‘custom’ sidebar, otherwise show a default.

    Where I’m stuck is, is_active_sidebar still returns true for the ‘custom’ sidebar even if the plugin returns false. Here’s my code:

    <?php
        if(function_exists('dynamic_sidebar')){
            if(is_active_sidebar('sidebar_custom')){
              dynamic_sidebar('sidebar_serivces_leadgen_footer');
            }
            elseif(is_active_sidebar('sidebar_serivces_secondary_footer')){
              dynamic_sidebar('sidebar_serivces_secondary_footer');
            }
        }
    ?>

    Is there a way to check if the sidebar content is an empty string (which is the case when the sidebar is disabled on a page)? Or to have the plugin make its sidebar ‘think’ that it’s empty by returning false or exiting or something like that?

    Thank you in advance.

  • The topic ‘If sidebar content is empty string…’ is closed to new replies.