Custom sidebar not showing in the dashboard

Register sidebar. add_action( ‘widgets_init’, ‘wpse_123456_widgets_init’ ); function wpse_123456_widgets_init() { $args = array( ‘name’ => __( ‘Sidebar name’, ‘theme_text_domain’ ), ‘id’ => ‘unique-sidebar-id’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ); if ( function_exists (‘register_sidebar’)) { register_sidebar( $args ); } } … Read more

Hooking Into Widget Output Loop

Hook into ‘dynamic_sidebar’ and count how often it is called. You get the current active sidebar with key( $GLOBALS[‘wp_registered_sidebars’] ). add_action( ‘dynamic_sidebar’, ‘wpse_96681_hr’ ); function wpse_96681_hr( $widget ) { static $counter = 0; // right sidebar in Twenty Ten. Adjust to your needs. if ( ‘primary-widget-area’ !== key( $GLOBALS[‘wp_registered_sidebars’] ) ) return; if ( 0 … Read more

is_active_sidebar() not working

Try this in your functions.php function your_widget(){ register_sidebar(array( ‘name’ => ‘Footer Column 2’, ‘id’ => ‘footer-column-2’, // I also added the ID but doesn’t work ‘before_widget’ => ‘<div id=”%1$s” class=”omc-footer-widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h4>’, ‘after_title’ => ‘</h4>’ )); } add_action( ‘widgets_init’, ‘your_widget’ ); Call in footer.php with the ID. <?php if ( … Read more

What is the use case for the “Class” parameter in register_sidebar?

If you fill class parameter to register_sidebar function then the class sidebar-{class name} gets added to the div of that sidebar in the back end. For example if you register the sidebar using following code : register_sidebar( array( ‘name’ => __(‘Footer Widget One’, ‘wpbs-framework’), ‘id’ => ‘footer-01’, ‘class’ => ‘testing’, ‘description’ => __(‘The first footer … Read more

How to get the name and description of a sidebar in theme?

You can use the $wp_registered_sidebars global variable. Like this: global $wp_registered_sidebars; if( is_active_sidebar( ‘activity_calendar_en’ ) ): esc_html_e( $wp_registered_sidebars[‘activity_calendar_en’][‘name’] ); dynamic_sidebar( ‘activity_calendar_en’ ); endif; If you check the WordPress core for is_registered_sidebar function, you’ll see that it’s using this global variable too: function is_registered_sidebar( $sidebar_id ) { global $wp_registered_sidebars; return isset( $wp_registered_sidebars[ $sidebar_id ] ); } … Read more