WordPress.org

Ready to get started?Download WordPress

Forums

Hiding categories (5 posts)

  1. speechpoet
    Member
    Posted 9 years ago #

    The FAQ's advice for using my-hacks.php to hide categories (http://faq.wordpress.net/view.php?p=55) seems to be broken in 1.5. Any suggestions for changes?

    The hack currently reads:

    You can exclude a category’s posts from appearing on index.php by adding the following code at the top of the my-hacks.php (my-hacks.php should exist, and my-hacks.php support should be enabled in Options -> Miscellaneous )after the “<?php � line :

    if ((empty($_GET['cat']))&&(!preg_match('/wp-admin/', $_SERVER['REQUEST_URI']))) $cat = '-1'; //Replace 1 with your category

  2. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

  3. speechpoet
    Member
    Posted 9 years ago #

    Thanks! Solution number one is the most elegant (and easiest).

    For anyone else who's looking, you may also want (as I did) to exclude those categories from the list of categories. Couldn't be easier. In the sidebar template, change

    <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','') ?>

    to

    <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','7') ?>

    The last field is an array, whose value is the list of category IDs to be excluded from the category listing. More details at http://codex.wordpress.org/Template_Tags/list_cats .

    Gracias again for the help!

  4. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    http://codex.wordpress.org/Template_Tags/wp_list_cats

    wp_list_cats() is a little easier to work with.

    EDIT: Solution 1 may give you issues with how many posts show up on your main page (i.e. possibly fewer posts show up than you expect). Solution 2 may conflict with an odd plugin here or there.

  5. ceo
    Member
    Posted 9 years ago #

    Uhm, just to throw in my two cents - the legacy hack is working fine on my site and I didn't edit a thing.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.