[resolved] Display only some of the categories of a post - filter? (3 posts)

  1. maorb
    Posted 6 years ago #


    Suppose I have a post which is assigned to categories A, B and C.
    When viewing the post, one should regularly see the output of the_category() as something like: filed under categories A, B, C.

    I'd like to exclude one of the catregories to be viewed, although the post will still be assigned to that, meaning - the user will see something like - filed under categories: B, C.

    Category A is a fixed one, meaning I will want always to exclude A from being displayed on a post, so it might be even easier.

    How can I filter that? Will be happy for ideas.


  2. maorb
    Posted 6 years ago #

  3. maorb
    Posted 6 years ago #

    Found a solution. Change the word "out" to the name of the category to exclude from list.
    Enjoy the code

    foreach((get_the_category()) as $category) {
    if ($category->cat_name != 'out') {
    echo 'term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.' ';

Topic Closed

This topic has been closed to new replies.

About this Topic