register sidebar, before_widget: get post category
-
Is there a way to add the category of each post into the widget code in functions.php so that they can be targeted by category in the CSS? I found directions to do this in the Loop: e.g.
<div id="post" <?php post_class(); ?> >
Here is one of my added sidebars in functions.php:register_sidebar(array( 'id' => 'basic', 'name' => __('Basic Sidebar'), 'description' => __('Sidebar used on most pages'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => "</aside>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ));
This assigns two classes to each widget: “widget” and the name of the widget or the plugin that generated the widget, but if I use the same plugin to add more than one widget there’s no consistent way to target them individually.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘register sidebar, before_widget: get post category’ is closed to new replies.