remove widget headings in sidebar
-
Hi all,
is there anyway I can remove the <h2> widget headings in a widgetized sidebar? In particular, I’d want to get rid of the Categories heading (I’m using the My Category Order plugin by the way).
TIA,
grazz
-
Hey,
I don’t use this widget, but these are suggestions…
One way is to identify the h2 widget ID or class in the stylesheet, and use display: none. That has worked for me in the past.
Another way is to enter mycategoryorder.php, which ships with the plugin, and find the code that contains the argument for the h2 ‘Categories’ heading and change it to the null value.
Good luck!
Hi,
good to read you again ??
I’d thought about display:none but I would really love to not go away with this by using a trick.
As to the second solution, it can’t be done ’cause the heading isn’t generated by the plugin but it’s set in the widgets file.
My idea of a working solution is something like a php control function that would recognize the widget and tell it not to generate an h2, but I’m waaaay too dense about php to achieve something like that ??
Ah, another way to do it (maybe a little friendlier) is modify your functions.php. For a widgetized sidebar, it looks like this:
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ));
I believe if you just leave a null value like below, it just titles default unstyled body text:
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '', 'after_title' => '', ));
To get rid of the title, do this:
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="none">', 'after_title' => '</h2>', ));
Or use a span:
if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<span class="none">', 'after_title' => '</span>', ));
In the stylesheet:
.none { display: none; }
Admittedly, though, this eliminates the title in every widget in that particular sidebar, rather than focusing on a particular widget. To work around that, one would have to set up additional sidebars for different widgets, based on display header, not display header,etc. etc.
I don’t want to modify the core, so I guess the next option would be to deploy a conditional tag to display the title only in a specific widget (eliminate title in other widgets), which is where you’re at now. Research continues…maybe a php guru wants to jump in.
Hey,
I had actually already spotted the code above (thanks for the effort anyway), and my idea was to use PHP to tell the code that when ‘before_widget’ is equal to the html generated for the categories heading (an li with a particular id is generated), then ‘before_title’ and ‘after_title’ should be null.
Then again, I do not know how to do that. Does anybody? That would be much appreciated!
Hi 11worth, bloggingcss.
I’ve been trying to get rid of the h2 titles before my widgets as well. I’ve tried all the methods mentioned above and they have all worked to an extent, but when viewing in IE still seems as though there is some kind of h2 tag there (although it doesn’t seem to be rendering in the html). Even when I create a new style in the css and refer to it in the functions.php (even when I use display: none) it sets the widget slightly lower in the sidebar than it should be.
I hope that makes sense to you! Any ideas?
It displays perfectly in all other browser of course!
Thanks for your time.
i gotta quick “hack” solution if you’re in a bind: hit the space bar when your cursor is in the widget title. thus, the title becomes “blank space” (i suppose it’s
nbsp;
).Hey guys, I’m so glad I found this post. I’ve also been toiling over the last couple of days on this. I found a solution (if you are still looking for one). For some reason, none of the above ideas worked within my Firefox, so I added a “style=’display: none'” to the
‘before_title’ => ‘<h2 class=”widgettitle”>’,
statement within the function, and it seemed to work fine (although you would think there would be setting for this.
My function now looks like this:
‘before_title’ => ‘<h2 class=”widgettitle” style=”display: none”>’,
I don’t think this works for iPhone or Blackberry if you are developing for that, but it seems to work on my browsers. Let me know if you have any luck with it.
- The topic ‘remove widget headings in sidebar’ is closed to new replies.