WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Excluding categories from categories menu (5 posts)

  1. hj
    Member
    Posted 4 years ago #

    I'm wondering how to exclude categories from my themes built-in category menu bar, which I think is driven by this line of code in the header:

    <?php wp_list_categories('sort_column=name&title_li=&depth=4'); ?>

    Is there a recommended plugin for managing what appears in the defualt WP category menu? I'm just talking about the menu/navigation, not search or any other functions..just how to exclude categories from the menu. I have so many it's soon going to overrun the bar unless I can exclude some (or specifically 'include' some)

    any help appreciated.

    Hugh

  2. MichaelH
    Member
    Posted 4 years ago #

    The template tag, wp_list_categories(), has an exclude= argument. Also note that you could be "more restrictive" by changing your depth=4 to something smaller.

    <?php wp_list_categories('exclude=7,2,6,10,23&sort_column=name&title_li=&depth=4'); ?>

    Alternative using include:

    <?php wp_list_categories('include=9,5,4,8,21&sort_column=name&title_li=&depth=4'); ?>
  3. Michael Fields
    Themer
    Posted 4 years ago #

    instead of:
    wp_list_categories('sort_column=name&title_li=&depth=4');

    try:

    wp_list_categories('sort_column=name&title_li=&depth=4&exclude=1,2,3');

    where "1,2,3" are the ids of the categories the you wish to exclude in ascending order.

  4. hj
    Member
    Posted 4 years ago #

    Many thanks guys! Just what I wanted. Resolved.

    Hugh

  5. hj
    Member
    Posted 4 years ago #

    Oh by the way, Michael... http://wordpress.org/support/topic/334111?replies=12

    I got the pages up on a live server now. It's the sidebar and categories thread you were helping with.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.