WordPress.org

Support

Support » How-To and Troubleshooting » Remove current category from showing in the category archive posts lists

Remove current category from showing in the category archive posts lists

  • Hi!!!

    I have a problem an i hope that some one can help me
    I’m doing a blog and on each category post lists page (using archives.php), the post show all the categories they are in.
    For an example:

    CAT ONE ARCHIVES
    Post One, also on: Cat One, Cat two
    Post two, also on: Cat One
    Post tree, also on: Cat One, Cat five
    Post four, also on: Cat One, Cat two, Cat five
    ….

    The problem is… if i’m on Cat One archive page, the post all show ‘cat one’ an others if there is one but i wanted to remove the current category name from showing.

    The result i’m triyng to achive is:

    CAT ONE ARCHIVES
    Post One, also on: Cat two
    Post two
    Post tree, also on: Cat five
    Post four, also on: Cat two, Cat five
    ….

Viewing 1 replies (of 1 total)
  • You’d need to use Template_Tags/get_the_category to get the categories in that post then display those categories and skip the current category when doing that.

    In a category archive the current category:

    <?php
    if (is_category( )) {
    $current_cat = get_query_var('cat');
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Remove current category from showing in the category archive posts lists’ is closed to new replies.
Skip to toolbar