I have this code for sidebar in WordPress :-
register_sidebar(array(
'name' => 'Main sidebar',
'description' => 'main sidebar.',
'before_widget' => '<div id="blocks" class="siderbar box_outer %2$s" style="visibility: hidden;"><div class="widget">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="widget_title">',
'after_title' => '</h3><div class="wid_border"></div>'
));
In this cod will add every widget attribute style="visibility: hidden;"
, but i need to add this attribute for all widget else first widget.
How can do that by php or JQuery.
I believe that what you want to do would better be done with CSS rules in your stylesheet rather than with an embedded
style
tag that you dynamically manipulate with PHP.Remove
style="visibility: hidden;"
from yourregister_sidebar
argument and use something like the following instead (Proof of Concept):That is purely to make the two necessary rules apparent. You can run that code to get a feel for things if you’d like. You will need to swap
aclass
for the class you need to target– eithersiderbar
orbox_outer
I presume. And you probably want to write the rules into your main stylesheet.