Show only populated categories in Menu

This topic contains 3 replies, has 3 voices, and was last updated by  Paolo 5 years, 3 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #505105

    vivek
    Full Member
    Post count: 246

    I have a menu with CPT>Categories, and i am using the CPT Categories to show the categories (not individual custom links), which when addded to menu, shows each category

    However, while I have created many cateogies, some of these are for future use, so how can i show only those categories which have at least one published listing in them, in the menu, and hide the rest?

    Any suggestions please?

    thanks, Vivek

    #505133

    Guust
    Moderator
    Post count: 29970

    I don’t really understand … there is no option to add CPT categories to the menu, except by selecting all of them or the ones you want.
    Can you tell us step by step what you did, maybe with images or links?
    Thanks

    #505152

    vivek
    Full Member
    Post count: 246

    Sorry, Guust – i was not clear in my earlier message.

    I can select one or as many as I want, but i have selected all of them as categories (attaching screenshot) in Appearence>Menus.

    I meant to say that i have not added individual custom links with category URLs, but used the CPT categories ‘widgets’ to add them to the menu.

    As i have about 100 categories and will be adding listings regularly (and even users will add listings) , so it will be difficult to manually keep track which categories are populated at any time or not. To start with maybe only half the cateogories may have a listing, so there will be many empty categories- hence i wanted to ‘hide’ these in the menu, and then they show automatically when the first listing is published.

    thanks, Vivek

    #505181

    Paolo
    Site Admin
    Post count: 31206

    This would require the code to query each category to see if empty before showing the link, it’d slow down page loading by a lot, especially if you have that many categories.

    Better to either avoid creating empty categories and add the category only once at least one listing is created, or do as Guust suggested.

    Thanks

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount