How to add multiple custom widget areas

I’m looking to add multiple widget areas to a page in my theme as id like to have widgets within certain pages. I can add one using this code, I’m just struggling with a second. function new_sidebar_widget_init() { register_sidebar( array( ‘name’ => ‘new-sidebar’, ‘id’ => ‘new-sidebar’, ‘before_widget’ => ‘<div id=”new-sidebar”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => … Read more

Widget area inside a widget

I tried putting dynamic_sidebar(‘widget-id’) inside a custom widget I created and it worked. The only thing I can’t figure out is how I can do this through a loop. Is there a way that when the widget is active, it registers a sidebar automatically with the same id as the dynamic_sidebar function inside it? 0

Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying

I am registering sidebars and sidebar widgets. The theme currently supports two sidebars. Primary and Secondary. add_action(‘widgets_init’, array($this, ‘add_sidebars’), 10, 2); public function add_sidebars(){ register_sidebar(array( ‘name’ => ‘Primary Sidebar’, ‘id’ => ‘mbe-sidebar-primary-sidebar’, ‘description’ => ”, ‘class’ => ‘mbe-sidebar’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h3 class=”widget-title”>’, ‘after_title’ => ‘</h3>’ )); … Read more

is_active_sidebar() not working

why the is_active_sidebar() function return always false? Function.php code: if ( function_exists(‘register_sidebar’) ) { 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>’ )); } footer.php code: <?php if ( is_active_sidebar( … Read more

How to avoid widgets added to sidebar on theme activation?

I am registering 3 sidebars on widgets_init register_sidebar(array( ‘name’ => esc_html__(‘Left Sidebar’,’creatus’), ‘id’ => ‘left’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<div class=”widget_title_holder”><h3 class=”widget-title”>’, ‘after_title’ => ‘</h3></div>’, )); // right sidebar register_sidebar(array( ‘name’ => esc_html__(‘Right Sidebar’,’creatus’), ‘id’ => ‘right’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => … Read more

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

I registered a new sidebar and filled in the class parameter (see code), I then dropped in an Archive widget and went hunting for my “testing” class. Not there. So what is the class parameter used for. Can I see an example? register_sidebar( array( ‘name’ => __(‘Footer Widget One’, ‘wpbs-framework’), ‘id’ => ‘footer-01’, ‘class’ => … Read more

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

I have a sidebar registered (in functions.php) as: <?php register_sidebar( array( ‘name’ => __(‘Activity Calendar’), ‘id’ => ‘activity_calendar_en’, ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ”, ‘after_title’ => ”, )); ?> In my theme I am calling it as: <?php if( is_active_sidebar( ‘activity_calendar_en’ ) ): dynamic_sidebar( ‘activity_calendar_en’ ); endif; ?> Now my question is: … Read more

Add div class to only one widget

I want to add more classes in the div tag of my search widget. My search is located in the sidebar together with other widgets. My code: function NT_widgets_init() { register_sidebar( array( ‘name’ => __( ‘Sidebar’, ‘side’ ), ‘id’ => ‘sidebar’, ‘description’ => __( ‘Rechte Spalte’, ‘rechts’ ), ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ … Read more