In my sidebar every widget title is enclosed in <h2>
tags.
I use 4 widgets in my sidebar and I’d like to have the first 2 widget titles as <h2>
and the other 2 as <h4>
.
I changed in my function.php as given below:
'before_title' => '<h4>',
'after_title' => '</h4>',
but that changes all titles.
How can I solve this issue?
dynamic_sidebar_params
is the filter that lets you modify those parameters on a per-widget basis. It fires for every sidebar though, so you’ll need to use bothadd_action
&remove_action
call. Tryvar_dump
once before writing the code to get an idea of what you have to doADDED AN EXAMPLE ON REQUEST
This example adds an extra class to each widget depending on the order in which they appear i.e. first widget will have class “widget-1”, 2nd will have “widget-2” & so on