register_sidebar – whats the purpose of "class"? It doesn't do anything?
-
register_sidebar() takes some $args.
<?php $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>' ); ?>
I’m trying to add a class to the inner-most HTML where the given widget will be inserted.
Example:
<div class="panel panel-default home-beside-content"> <aside class="widget widget_text" id="text-8"> <div class="row panel-heading"> <h3 class="featured-posts col-md-12">This is a test</h3> </div> <div class="textwidget">This is a test</div> </aside> </div>
I’d like to add the class “panel-body” to the textwidget area. Like so:
<div class="textwidget">This is a test</div>
Becomes:
<div class="textwidget panel-body">This is a test</div>
Its very important this class is put here in particular because bootstrap requires this nesting.
https://getbootstrap.com/components/#panels
So when I add the class to the args, nothing happens — hence I ask how do you insert a class into this part of the widget? I would assume by doing this:
<?php $args = array( 'name' => __( 'Sidebar name', 'theme_text_domain' ), 'id' => 'unique-sidebar-id', 'description' => '', 'class' => 'panel-body', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' ); ?>
But the class shows up nowhere in the HTML.
I am desperately in need of help on this one ?? Thank you.
- The topic ‘register_sidebar – whats the purpose of "class"? It doesn't do anything?’ is closed to new replies.