WP_GET_CATEGORIES Might Duplicate the Categories Subtitle in Your Sidebar
I’ve been tweaking the WordPress theme used over at Brothers In Blog (my second blog I coauthor with my brother). Last week I added category and archive totals to the sidebar. One of the things I noticed, which wasn’t there all along, is that my “categories” subtitle appeared twice. If your selected WordPress theme originally used the deprecated template tag “wp_get_cats” and you recently updated the template tag to the newer supported tag, “wp_get_categories”, you might have created some sidebar subtitle redundancy. Here’s what I mean and how to correct it.
What do you mean, redundant subtitles?
The theme I selected included images for popular sidebar sections such as Categories, Archives, Pages, etc. The selected theme also used a deprecated WordPress template tag “wp_list_cats” to display my site’s categories in the sidebar. I wanted to display a post total for each category. During my template tag option research I discovered the tag was replaced with “wp_get_categories.” I updated to the new tag and added “show_count=1″. I got the totals I wanted, but I also got a duplicate section subtitle - “categories.”

Remove the default categories subtitle from your sidebar
The “categories” subtitle appears because the new “wp_get_categories” template tag has an option called “title_li”. By default, this option gets set to “_Categories”; however, if explicitly added to the new tag and left empty, then nothing gets displayed. Since “nothing” is exactly what I want, I add the option inside the parenthesis along with the “show_count=1″, which changed the option to “show_count=1&title_li=” and gave me the output shown below.

Note: I am using double quotes in this post to call out the tags and options; however, in practice, template tag options are surrounded by single quotes inside the parenthesis. Also, the “title_li” option allows me to specify a different subtitle for my categories other than the default “_Categories”. For example, if I wanted to call my category “Topics”, then I would just add that text after the equal sign of the option — “title_li=Topics”
Template tag changes are something that theme designers need to be well aware of; however, if you’ve done some minor tweaks to your theme, you should also be aware of what has changed in WordPress 2.x (assuming you recently upgraded to WordPress 2.x). You can find a complete list of deprecated template tags in the developer doc section of the WordPress.org website.
Share, Bookmark, or Email this post
If you liked this post, subscribe to TechTraction's RSS feed or TechTraction's email feed
Filed under: How-To & Tech Tips

Leave a Reply