• Resolved Nic727

    (@nic727)


    Hi,

    I’m trying to hide uncategorized category to show on posts. I tried :

    if (!has_category($category = 'Uncategorize')): (didn’t do anything)
    and
    if (has_category($category != 'Uncategorize')): (Removed all categories)

    How to hide un Uncategorized category from showing up?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your code doesn’t make sense.
    You can remove the Uncategorized category from your posts. Empty categories don’t show up anywhere.
    If you insist on using code, look at the examples here: https://developer.www.ads-software.com/reference/functions/has_category/#user-contributed-notes

    Thread Starter Nic727

    (@nic727)

    I know my code doesn’t make any sense lol. My problem is that I read this page about has_category() and I can’t find a way to make it works. The problem is that if I unselect all categories from my post, it put “Uncategorize” by default. I can’t choose an empty category.

    EDIT: Well, I guess I just have to make sure I always add a relevant category to my post even if it’s a random post about anything…

    • This reply was modified 3 years, 6 months ago by Nic727.
    Moderator bcworkz

    (@bcworkz)

    You could change the default category to one called “Miscellaneous” or whatever. IMO it’s not worth fighting WP over what it wants to do in requiring some category be assigned. If having a particular term show up on the front end bothers you, that’s relatively easy to suppress. Forcing no assignment at all isn’t so easy.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘If doesn’t have “Uncategorized” category, show the categories – Not working’ is closed to new replies.