I've replaced the WP search on my site with a Google CSE. Google has a nice feature that lets you specify that certain areas of the page should not be indexable, by adding a "nocontent" class to those sections. I need to add this class to all the sidebars.
I've tried adding a filter to register_sidebar, and the data is changed in the function, but the change that I make is not passed into the output.
add_action( 'register_sidebar', 'uft_add_nocontent_class' );
function uft_add_nocontent_class( $sidebar_info ) {
$sidebar_info['before_widget'] = str_replace('class="widget ','class="widget nocontent ',$sidebar_info['before_widget']);
return $sidebar_info;
}
I also tried this with an action with similar lack of success. Should I just modify the child theme, or is there another way to make the hook work?