Opened 11 years ago
Closed 9 years ago
#27156 closed enhancement (wontfix)
add filter to manipulate $before_title and $after_title in widget
Reported by: | sireneweb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.8.1 |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
Hi,
actually you can't manipulate correctly the params for before_title and after title, it would be great to add a filter to manipulate them and better if we can specify for which widget based on widget type & location more simplier.
To know the widget_id, you need to print the request with var_dump
Actually i use this :
add_filter ( 'dynamic_sidebar_params' , 'rename_widget_title'); //we use the default priority and 3 arguments in the callback function function rename_widget_title($params) { $widget_request_1 = array('nav_menu-6','nav_menu-2','"nav_menu-5','categories-2'); $widget_request_2 = array('custom_post_widget-4'); if (in_array($params[0]['widget_id'],$widget_request_1)){ $params[0]['before_title'] = '<span class="widgettitle">'; $params[0]['after_title'] = '</span>'; }elseif(in_array($params[0]['widget_id'],$widget_request_2)){ $params[0]['before_title'] = '<span class="title_bloc_widget">'; $params[0]['after_title'] = '</span>'; } return $params; }
Maybe we can display in back office in widget panel the widget id with hover when the mouse is on the title of widget.
Change History (3)
#2
@
11 years ago
No i don't want change the class, but i want to change the element. Instead of use h2 or h3 i want to change by span for SEO.
Version 0, edited 11 years ago
by
(next)
Note: See
TracTickets for help on using
tickets.
Hello sireneweb, thanks for your report.
Why do you want to change $before_title and $after_title? Looking at your example your are just changing the class name, probably for styling purposes. A sidebar can also register $before_widget which includes an ID and a class name.
Based on your example something like the following should work too: