Viewing 13 replies - 16 through 28 (of 28 total)
  • UPPP

    Check the docs or create a properly contexted question that explains what you want to do…

    Bumping a post with Up!! UPP!! etc is not going to earn you any special help.

    I have already check the codex but , I don’t understand where i can put the ID category I want to hide in the code of MichaelH !

    If you can help me thx a lot ??

    i replace the code <?php the_category(‘, ‘); ?> , and i don’t know where I place the “exclude=204” (204 it s the number of my category )

    Replace…

    cat_to_exclude

    with the name of the category…

    Using Michael’s example…

    You use the category name and not the ID… it’s quite self explanatory if you look at the code…

    <?php
    // For each of the categories, create them as category variables
    foreach((get_the_category()) as $category) {
        // If the category is NOT the cat_name (category name) then echo some stuff
        // So grab all... except where they match cat_name (exclude basically)
        if ($category->cat_name != 'cat_to_exclude') {
        echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
    }
    }
    ?>

    I added a few comments in there (the code will still work), but it should be obvious.

    oh ok, thx a lot ??
    it works !

    Hello,

    This was really helpful.

    How do I go about hiding more than 1 category using this method?

    Bump

    Any assistance would be greatly appreciated.

    WP Themes

    Yeah you should be able to do something like this… (untested)

    Change this line…
    if ($category->cat_name != 'cat_to_exclude') {

    To…

    if ($category->cat_name != 'cat_to_exclude' or 'another_cat_to_exclude') {

    Let me know if that works for you…

    I tried this but it didn’t work

    if ($category->cat_name != 'Past Project' or 'Current Project') {

    Try this instead then..

    if ($category->cat_name != 'cat_to_exclude' || $category->cat_name != 'another_to_exclude') {

    Hmm.. Can’t get that last one working either..

    if ($category->cat_name != 'uncategorized' || $category->cat_name != 'featured') {

    This hides “uncategorized” just fine, but “featured” still shows up.

    Did anyone figure out how to hide more than one category?

    Any help would be appreciated. Thanks.

    Or you could use a plug-in .. Advanced Category Excluder

Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘how to hide category listing in post’ is closed to new replies.