Can you really obtain the title from the icons which i have enabled during my sidebar in order to place that like a reputation for my class attribute?

For instance: 'before_title' => <h2 class="title of the widget">',

Basically inspect the element, I wish to see: <h2 class="author"> and <h2 class="links"> etc...


It's certainly possible, but when for you to do it dynamically, you'd want to use a filter.

The dynamic_sidebar_params filter should meet your needs. If you are not really acquainted with what filters do, essentially a filter enables you to definitely edit content of all time shown on screen or held in the database. See more here:

Within the dynamic_sidebar_params filter, the passed array has got the following structure (I acquired this from carrying out a print_r)

    [0] => Array
            [name] => Primary Widget Area
            [id] => primary-widget-area
            [description] => The primary widget area
            [before_widget] => <li id="search-2" class="widget-container widget_search">
            [after_widget] => </li>
            [before_title] => <h3 class="widget-title">
            [after_title] => </h3>
            [widget_id] => search-2
            [widget_name] => Search

    [1] => Array
            [number] => 2


To ensure that means, all you want do is edit the $params array before coming back it. You may have to complete some conditional logic too to obtain the exact class that you would like, but I'll leave that your decision.

Here's a good example:

function my_edit_widget_func($params) {
    $params[0]['before_title'] = '<h3 class="' . $params[0]['widget_name'] . '">' ;
    return $params;
add_filter('dynamic_sidebar_params', 'my_edit_widget_func');