WordPress.org

Ready to get started?Download WordPress

Forums

Remove current category from showing in the category archive posts lists (2 posts)

  1. H R
    Member
    Posted 4 years ago #

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

  2. MichaelH
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags