Support » WP-Advanced » Hide categories in WP category widget

Hide categories in WP category widget

  • archeoit


    I’d like to hide some categories in wordpress category widget. Is it possible?

Viewing 15 replies - 1 through 15 (of 15 total)
  • MichaelH


    You’d have to modify wp-includes/widgets.php and change the use of the template tag, wp_list_categories(), to use the exclude= parameter.

    Please note that modifying core files is generally discouraged, so make a backup of the file(s) before changing anything–just in case it doesn’t work you’ll have something to fall back on. Also, remember you will need to ‘retrofit’ that change upon subsequent WordPress upgrades.



    Thanks MichaelH for your reply.
    Yes i know that it’s possible to have it working just hacking the WP core, but i’d like to do it without any hack.
    Is it possible?
    Is there a plug-in that make it possible?
    Better, instead of use category widget, can i make a simple widget plugin and use it instead of WP category plugin? or is this an hard code work?



    Find this line in widgets.php

    $cat_args = “orderby=name&show_count={$c}&hierarchical={$h}”;

    and add the &exclude= to the end of it, eg. to exclude cat’s 1, 2 & 3

    $cat_args = “orderby=name&show_count={$c}&hierarchical={$h}&exclude=1,2,3”;

    It would be better to copy the category widget code and make a seperate widget with the exclude as an option tho and include it in your template. I’m not sure why this feature is left out as standard though because the page widget has it.

    Holy crap I have been trying to figure out how to do this for about six hours now. Thank you so much that worked perfectly.

    Shouldn’t we be able to copy the exclude code from the page widget and add it to the category widget?

    I have been working on it but have not succeeded yet.

    I tried editing the widgets.php file as indicated, and still no luck. Both of the categories I tried to exclude are still showing up.

    Here’s what I ended up doing: installing exec-php plug-in (which allows you to use php in text widgets, amond other things), then creating my own text widget with this code:

    <?php wp_list_cats(‘exclude=11,12’);?>

    Teknishun’s method worked great for me.

    My situation was I needed to make a “find a dealer” type of search for this site. I read in another article, “put the zip code tags in the post”. So, I did this… all was good except now the post showed up in a misc. category. I did not want this, as I felt it was sloppy so I decided to seek out a way to hide that category. Now I can have my “locations” category hidden from the general public. The results still show up in search.

    How enlightening! 🙂 Thank you!

    Is there a way to do this in WordPress 2.5? I can’t find the line Teknishun suggests in my widget.php. Has it all changed in 2.5?

    I can’t find it neither, assuming that the file is placed in wp-admin/widgets.php

    The same question, I tried editing the widgets.php file as indicated at my page puppy names, also Still fail.

    Not sure about the plugin, but check http://codex.wordpress.org/Plugins/Plugin_Compatibility/2.3 or http://codex.wordpress.org/Plugins/WordPress_Widgets
    thank, I’ll see to it.

    Me helped this plugin. http://blog.avirtualhome.com
    In wordpress 2.6 when I use widgets – all function tags in template not working. This plugin add a new widget with my categories. But I want add many widgets of categories, pages and all them made individual options. Now, in the Wordpres 2.6.1 its not real…

    Мне помог этот плагин. Создаёт виджет “Рубрики”, настраивается список отображаемых категорий.

    Thanks MichaelH for your reply.

    [sig moderated]

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Hide categories in WP category widget’ is closed to new replies.
Skip to toolbar