Title: Using has_term
Last modified: July 26, 2019

---

# Using has_term

 *  Resolved [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/)
 * (@joefedorowicz)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/)
 * Hello, I’d like to do a thing based on whether or not something is in an event
   category. This isn’t working.
 * Help?
 *     ```
       if(has_term( 8, 'term_id' )) { 
       		    $hidetitle = " no-title";
       		} else {
       		    $hideexcerpt = "";
       		}
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11769480)
 * hi,
 * sorry but can I know where are you trying to use the above snippet?
 *  Thread Starter [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/)
 * (@joefedorowicz)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11769929)
 * As a conditional to do some stuff. That appears on my front page within a query.
 * I just would like to know what the best way to check against a term (specifically
   a category) is?
 *  [Stonehenge Creations](https://wordpress.org/support/users/duisterdenhaag/)
 * (@duisterdenhaag)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11770955)
 * The event category is saved within the EM_Event Object, so you cannot retrieve
   is with a simple “get_term()”.
 * You will first have to get into the correct Object.
 * Please post your full query so we can look what exactly needs be altered. A very
   small part is just not clear enough 😉
 * Also, please provide a link to the front page you are speaking of. It really 
   helps.
 *  Thread Starter [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/)
 * (@joefedorowicz)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11772098)
 * Relevant part bolded
 *     ```
       	while ( $loop->have_posts() ) : $loop->the_post();
   
       		$thumb_id = get_post_thumbnail_id();
       		$hello = get_post_meta($post->ID, 'event_id', true);
       		$thumb_url = wp_get_attachment_image_src($thumb_id, 'slider1', true)
   
       ***RELEVANT PART***
       		if(has_term( 7, 'term_id' )) { 
       		    $hideexcerpt = " no-excerpt";
       		} else {
       		    $hideexcerpt = "";
       		}
   
       		if(has_term( 8 )) { 
       		    $hidetitle = " no-title";
       		} else {
       		    $hideexcerpt = "";
       		}
   
       ***END RELEVANT PART***
   
       		$content .= '<li><div class="slider-post ';
       		$content .= '"><a href="';
       ```
   
    -  This reply was modified 6 years, 8 months ago by [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/).
 *  Thread Starter [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/)
 * (@joefedorowicz)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11774089)
 * [https://jx2development.com/library/](https://jx2development.com/library/)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using has_term’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [joefedorowicz](https://wordpress.org/support/users/joefedorowicz/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/using-has_term/#post-11774089)
 * Status: resolved