WordPress.org

Forums

Hide categories in WP category widget (16 posts)

  1. archeoit
    Member
    Posted 7 years ago #

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

  2. MichaelH
    Member
    Posted 7 years ago #

    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.

  3. archeoit
    Member
    Posted 7 years ago #

    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?

  4. MichaelH
    Member
    Posted 7 years ago #

  5. Paul Phillips
    Member
    Posted 7 years ago #

    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.

  6. changethethought
    Member
    Posted 7 years ago #

    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.

  7. coppertopjsq
    Member
    Posted 7 years ago #

    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.

  8. bricksmith
    Member
    Posted 7 years ago #

    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.

  9. bricksmith
    Member
    Posted 7 years ago #

    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');?>

  10. munkee
    Member
    Posted 7 years ago #

    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!

  11. Fleishman
    Member
    Posted 7 years ago #

    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?

  12. plusarquitectura
    Member
    Posted 7 years ago #

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

  13. msnty1
    Member
    Posted 7 years ago #

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

  14. msnty1
    Member
    Posted 7 years ago #

    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.

  15. Sergei Boldyrev
    Member
    Posted 7 years ago #

    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...

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

  16. onthink
    Member
    Posted 6 years ago #

    Thanks MichaelH for your reply.

    [sig moderated]

Topic Closed

This topic has been closed to new replies.

About this Topic