dynamic_sidebar example

/** * Displays the footer widget area. * * @package WordPress * @subpackage Twenty_Twenty_One * @since Twenty Twenty-One 1.0 */

if ( is_active_sidebar( 'sidebar-1' ) ) : ?> <aside class="widget-area"> <?php dynamic_sidebar( 'sidebar-1' ); ?> </aside><!-- .widget-area --> <?php endif;


        // Filter sidebars_widgets so that only the queried widget is in the sidebar.         $this->rendering_widget_id = $widget_id;

        $filter_callback = array( $this, 'filter_sidebars_widgets_for_rendering_widget' );
        add_filter( 'sidebars_widgets', $filter_callback, 1000 );

        // Render the widget.         ob_start();
        $this->rendering_sidebar_id = $context['sidebar_id'];
        dynamic_sidebar( $this->rendering_sidebar_id );
        $container = ob_get_clean();

        // Reset variables for next partial render.         remove_filter( 'sidebars_widgets', $filter_callback, 1000 );

        $this->context_sidebar_instance_number = null;
        $this->rendering_sidebar_id            = null;
        $this->rendering_widget_id             = null;

        return $container;
    }

    
sprintf( __( 'Theme without %s' )basename( __FILE__ ) ),
    '3.0.0',
    null,
    /* translators: %s: Template name. */
    sprintf( __( 'Please include a %s template in your theme.' )basename( __FILE__ ) )
);
?> <div id="sidebar" role="complementary"> <ul> <?php             /* Widgetized sidebar, if you have the plugin installed. */
            if ( ! function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar() ) :
                ?> <li> <?php get_search_form(); ?> </li> <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it. <li><h2><?php _e( 'Author' ); ?></h2> <p>A little something about you, the author. Nothing lengthy, just an overview.</p> </li> -->
<?php     }

    if ( ! empty( $description ) ) {
        ?> <div class="sidebar-description"> <p class="description"><?php echo $description; ?></p> </div> <?php     }

    dynamic_sidebar( $sidebar );

    echo '</div>';
}

/** * Retrieves the widget control arguments. * * @since 2.5.0 * * @global array $wp_registered_widgets * * @param array $params * @return array */
Home | Imprint | This part of the site doesn't use cookies.