How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?

If you want to add a class before each widget you should use the dynamic_sidebar_params filter. Another post explains this well. Here’s the gist of it. function uft_add_nocontent_class($params) { $params[0][‘before_widget’] = ‘<aside id=”%1$s” class=”widget %2$s nocontent”>’; return $params; } add_filter(‘dynamic_sidebar_params’, ‘uft_add_nocontent_class’); Otherwise, go and edit your child theme files. If you don’t have a lot … Read more

register_sidebar / dynamic_sidebar with sidebar id

Your code works when I test it. I can only assume that the registration code is being hooked into the system too early or too late. register_sidebar() should be hooked on widgets_init per the Codex. Therefore: function register_header_sidebar_wpse_190618() { register_sidebar( array( ‘id’ => ‘header-sidebar’, ‘name’ => ‘Header’, ‘before_widget’ => ‘<div class=”widget”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ … Read more

Undefined index: custom_sidebars

Sounds like $my_theme_option has no ‘custom_sidebars’ index, if you’ve remove it, it does not exist anymore. just add a if isset() around it, just like you did at around the for loop Also you don’t need to check for functions like register_sidebar to exist if they are older then 2 years. EDIT: DONT USE GLOBALS! … Read more