Only Show Categories with Listings in Menu

This topic contains 2 replies, has 2 voices, and was last updated by  purpleedge 9 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #12421

    purpleedge
    Expired Member
    Post count: 539

    Anyone know of an easy-to-implement menu hack that will only show categories which have listings?

    I’m adding quite a few categories to my menu and it’s a bit of a pain to do it manually, and I don’t want links to empty categories.

    #12488

    Paolo
    Site Admin
    Post count: 31206

    Hi Purpleedge,

    currently the only way to add categories to the main menu is through wordpress menu interface adding them 1 by one.

    In that case the category link will be displayed no matter if the category is empty or not.

    Given that this would be a wordpress hack, rather than a GD hack, I’ve googled “wordpress menu hide item if empty category” and I haven’t found a proper hack that would hook into the wordpress menu to hide empty categories. In wordpress forums the answer is:

    If you’ve added a link for a category to a custom menu, you can’t then dynamically hide it “on empty”. Just don’t add these links to your custom menus(s) unless you have at least 1 post in the relevant category.

    and even though it is 3 years old, I haven’t found anything that wouldn’t require hacking the theme menu, like explained here : http://wordpress.org/support/topic/hide-empty-categories-in-wp_nav_menu

    So, it doesn’t seems like there is any easy hack for this…

    Thanks

    #12517

    purpleedge
    Expired Member
    Post count: 539

    Thanks Paolo,

    I actually came across this plugin that might be able to do it? As soon as I have a spare minute I’ll have a look and report back.

    https://wordpress.org/plugins/category-posts-in-custom-menu/

    The WP menu manager is a pain, especially when the menu gets big, so another solution might entail going to a page with the GD categories listed and use that as a navigation aid.

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket