Sub Categories Widget

Sometimes when you divide up your WordPress content into categories it all ends up in sub-categories of one or two main categories that don’t have any content themselves.  With the widget you can add a list of sub-categories even if the parent doesn’t have posts.

Download

You can download this Widget from the WordPress Plugin Directory.

Please drop me a line if you use this plugin; I’d be interested to see how it is being implemented.

Features

There is the option to use the title of the parent category as the widget title or you can enter a different title.  Whichever title you choose there is an option to make that a link to the parent category.

You can choose to hide empty sub-categories (those without any posts) and you can also choose to show the number of posts in each sub-category.

If you want you can add a bunch of widgets, each showing sub-categories from a different parent.

Version History

1.5

  • Added an option to display the categories in reverse order
  • Added the ability to change the selection label text of the dropdown list

1.4

  • Added an option to use the first category of the post as the parent
  • Improved and updated sanitation and validation
  • Exclude is now a multiple selection list

1.3.1

  • Updated the dropdown to be in name order (to match the list)

1.3

  • Added option to show as drop-down list
  • Tidy of widget options area

1.2

  • Added ability to exclude categories (with a comma delimited list)
  • Added option to show the entire sub-category tree rather than just one level

1.1

  • Highlights the current category if on a category archive page (use .current-cat to style)

1.0

  • First production release

0.1

  • Initial release

33 Comments

  • James

    Hi, I love this widget but I have something weird happening. The sub-category list is showing on the website as expected but not for all main categories. Some main category sum-categories are showing but not all. Any ideas?

    • BC

      It’s a bit difficult to say what the issue could be, perhaps they are being excluded by your selections. It can also be an issue with posts with more than one category assigned – it only expects one category for the post.

  • Dustin Peerce

    Hi,

    I added the widget to my sidebar, but every category is being excluded automatically. It excludes pre-existing categories AND newly added categories. I can’t find a way to remove them from the list of excluded categories either. Clicking on the list entries does not allow me to interact with the list.

    • BC

      I’m not seeing this behavior myself and the widget is working fine. Perhaps it is a conflict with another plugin (although that seem unlikely). You could try disabling them one by one to see if that fixes it.

  • HTC

    Hello, how i can sort the categories list by day of creation or by category ID?

    Thank you.

    • BC

      You can only sort alphabetically not by creation date or ID, sorry.

  • Justin Munce

    Could you please make this plugin find the categories automatically?

    i want to implement it so that whatever page it is on, it will find the fourth-level category and display subcategories to the fourth-level category.

    For example:

    (On a page about South Sudan news, which is breadcrumbed: World > Africa > East Africa > South Sudan)

    I want to show all the sub-categories to South Sudan (cities/districts).

    If I was on an article about Vancouver Island (breadcrumbed World > North America > Canada > BC > Vancouver Island), it would display all sub-categories to BC).

    If this is possible, please email me. I may be able to provide some compensation if necessary. Thanks, Justin

    • Justin Munce

      Another, perhaps better way this could work is the plugin could find the deepest category (Juba, a sub-category to South Sudan), then show all categories at that level (all sub-categories to South Sudan).

    • BC

      If I understand what you are asking, then the widget already works this way if you select the option to use the first category of the current post as the parent and to display the whole tree.

      • Sean Young

        this is not working for me. I am creating a recipe site with the following structure

        Recipes
        — Appetizers
        — Dinner
        — Side Dishes

        etc.

        I have a recipe in DInner and Recipes. As soon as I select “Use first category of post as parent” and save, nothing shows in my sidebar. I have the latest version of wordpress and your plugin.

        Any thoughts are appreciated.

        • BC

          I’ve answered this on the WordPress site (but the summary is that it appears to work fine with my test data).

  • F Davies

    Perfect! Just what I was looking for. I wanted empty parent categories, and on the publicly viewed sidebar, I wanted listings of the subcategories to show under link-free titles. 5 stars from me!
    Just one perhaps negative note. IMHO, you might have better download results with a less busy and distracting graphic on your wordpress plugin description site. It might be excellent art but it doesn’t fit the simple elegance of the plugin.

    • BC

      Thanks for the positive feedback and I’m glad that you find the widget useful. The Bruegel print isn’t for everyone I guess; I like it myself and it does symbolise the sub-categories (little fish) coming from the parent (big fish). I’m not chasing download figures but hope that most people will try the widget and use it if they like it and accept my taste in art for what it is, even if it’s not for them.

  • Sarangan

    Thanks for a super plugin. I’m using it on my sites.
    Please add an option to list the categories by ordering in reverse alphabetical: ‘order’ => ‘DESC’

    Thanks.

    • BC

      This is possible and I will probably add it in the next version.

  • Tom Farrell

    Great Plugin and simple to get going too.
    I am using it on my site to Search by Career Area on the left hand side.

    Just one question- how can I get the subcategories sorted alphabetically?
    Thanks.

    • BC

      It should be alphabetical in the dropdown but the defaults for the list and dropdown functions aren’t the same. Thanks WP! This is fixed in 1.3.01.

  • Randal Oulton

    Dang! This is *exactly* what I need, what the world needs, lol. But I need the option for it to display as a drop down, the way the regular category widget in WP gives ya! Darn, darn, darn!

    • BC

      There is a new dropdown option in verison 1.3

  • Jane

    I just installed sub category widget. I am using Thesis 2.1.9, and I’m used to widgets not working with Thesis, so maybe this one doesn’t. I don’t see how to use it. The category edit page doesn’t seem to show anything different. If it does work with Thesis 2.1.9, could you give me some directions? Thanks, Jane

    • BC

      This plugin is just a widget. It doesn’t do anything to your categories. If you add the widget to your theme you’ll be able to work out what it can do from the settings in the widget. It will show a list of sub-categories for a given category in the widget area as a list. This acts as a sort of navigation. How this works for you depends a lot of how your content is categorized.

  • Sam

    Your widget literally solved a problem I was trying to resolve for 10 days–and some top wordpress experts had no idea how to do! So first of all thanks.
    As you can see here, I implemented your widget on my page to show one category and then I put in multiple instances of the widget so I can get a sort of directory of my site:

    http://parentcity.org/categories/

    I would like to make the first category (behavior) span two columns) is there a way to do that in custom CSS or some other way?

    • BC

      You can do this with most easily with css3, for example.

      http://css3clickchart.com/#multiple-columns

      Just add this to the widget container where you want the widget to span multiple columns.

      Either that or split the category into 3 or 4 sub-categories and divide it up that way.

  • Joe

    Is it possible to set this up on a category page instead of a side widget?

    • BC

      Sorry, it is not possible to display the output on a page as there is no short-code function for this plugin; it is just a widget.

  • Mike

    Hi,

    Great plugin. Is it possible that the widget takes the category of the page automatically for showing the sub category ?

    • BC

      This has now been implemented in version 1.4

  • Karin

    I would like the subcategories to only show while in the parent category. Is this possible?

    • BC

      Do you mean that you want to only show a list of sub categories if you are viewing the page for the parent and if you are viewing any other page the widget shows nothing at all?

      I think that is a nice idea, but I am not certain if the widget knows anything much about the page on which it is displayed. I will look into it a bit.

      • Hazar K.

        Actually this user’s request was exactly what I needed this plugin for, I ended up modifying the code myself to serve this purpose. I was wondering if you’d be interested in updating the plugin to add this feature for all users. If so, contact me and I’ll send you my code. Thank you for the plugin!

        • BC

          That’s great and I’m glad it’s working for you. I’d be interested to know what you did to pick up the correct category in the plugin.

  • Denise Young

    Is it possible to order the categories in a specific order? Not alphabetical??

    Thank you!

    • BC

      I assume that by specific order you mean in an order which you select somehow?

      If so I don’t think that will be possible for this simple widget since there is nowhere in the widget to view, sort and order the sub-categories.

      The only other available sorting options are by slug or description and I’m not sure that’s so useful – it depends on your implementation I guess.

Leave a Comment

Your email address will not be published. Required fields are marked *