Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:17:57+00:00 2026-06-01T18:17:57+00:00

I have a custom post type in which I have custom taxonomies setup. I

  • 0

I have a custom post type in which I have custom taxonomies setup.

I want to print out the categories(custom taxonomy) that a post is included in, but exclude one. I cannot find a solution to exclude the category though.
Here is my code to output a list of the categories the custom post type is filed under:

<?php the_terms( $post->ID, 'critter_cat', 'Critter Type: ', ', ', ' ' ); ?>

How do I exclude a specific category?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:17:58+00:00Added an answer on June 1, 2026 at 6:17 pm

    You could create a function in your functions.php file that calls get_the_terms to return the list of terms as an array and then remove the item you don’t want.

    Give this a try:

    function get_excluded_terms( $id = 0, $taxonomy, $before = '', $sep = '', $after = '', $exclude = array() ) {
        $terms = get_the_terms( $id, $taxonomy );
    
        if ( is_wp_error( $terms ) )
            return $terms;
    
        if ( empty( $terms ) )
            return false;
    
        foreach ( $terms as $term ) {
            if(!in_array($term->term_id,$exclude)) {
                $link = get_term_link( $term, $taxonomy );
    
                if ( is_wp_error( $link ) )
                    return $link;
    
                $excluded_terms[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
                }
        }
    
        $excluded_terms = apply_filters( "term_links-$taxonomy", $excluded_terms );
    
        return $before . join( $sep, $excluded_terms ) . $after;
    }
    

    and then use it like this:

    <?php echo get_excluded_terms( $post->ID, 'critter_cat', 'Critter Type: ', ', ', ' ', array(667)); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom post type called song and i want to query the
I have a series of posts within a custom post type which are all
i have created a custom post type named Books & i have a widget
I have 2 custom post types - offered and wanted. I want these items
On a related post I mentioned that I have found custom HTML helpers to
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have a post type which is used to upload banners in wordpress. Using
I've created a custom post type and a custom taxonomy to go with it.
I have a custom Http Handler which manipulates HTTP POST and GET. I got
I have created a custom post type calles articles and a custom category like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.