I have Dynamic sidebars that are generated based on terms of a taxonomy that were created.


public function __construct() {
    add_action('widgets_init', array($this, 'checkForActiveSidebarAndMenu'));   
public function checkForActiveSidebarAndMenu() {
    //global $wp_registered_sidebars;
    $terms = get_terms(array('taxonomy'=>'minisite','hide_empty'=>false));
    foreach($terms as $term) {
        update_term_meta($term->term_id, 'sidebar_active', '1');
        //update_term_meta($term->term_id, 'menu_active', '1');
public function registerSidebars($mini_site_id) {
    // Register main content sidebar, [MINISITENAME]_[TERMID]_HOMEPAGE
    // Register right aligned sidebar, [MINISITENAME]_[TERMID]_RIGHT_SIDEBAR
    $mini_site_name = get_term($mini_site_id, 'minisite');
    $mini_site_name = $mini_site_name->slug;
    $sidebar_name = $mini_site_name . '_' . $mini_site_id;
    $args = array(
        'id'=>$sidebar_name . '_HOMEPAGE',
        'name'=>$sidebar_name . ' HOMEPAGE'
    $args = array(
        'id'=>$sidebar_name . '_RIGHT_SIDEBAR',
        'name'=>$sidebar_name . ' RIGHT SIDEBAR'

This function registers the sidebar. The query array in "get_terms" will change.

This is my second function that I've written as initially I was under the impression that sidebars only need to be registered once, not every single 'widgets_init'

The above code creates the sidebar every time widgets_init runs which means that I can populate my sidebar with widgets, refresh and the new sidebar would be there and the old one gone.

What am I doing wrong? I want to be able to register a dynamic sidebar and for it to stay until I unregister it.


  • The class is fine and the methods are executing as they should.

  • The taxonomy "minisite" is my taxonomy and it works fine, it loads as priority 0 on 'init' to allow for widgets_init to run with that taxonomy correctly.

1 Answer 1


The solution was simple and made me feel tremendously stupid. 90% of the issues I could find remotely similar to my issue were all issues relating to the casing. Throughout this whole process I overlooked the "_HOMEPAGE" and "_RIGHT_SIDEBAR" in my IDs.

Those should be lowercase.

id - Sidebar id - Must be all in lowercase, with no spaces (default is a numeric auto-incremented ID). If you do not set the id argument value, you will get E_USER_NOTICE messages in debug mode, starting with version 4.2.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.