Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answermy answer to this question: Is There a Difference Between Taxonomies and Categories?Is There a Difference Between Taxonomies and Categories?

As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts the term as first parameter and the taxonomy name as second parameter. So your condition should look like this: (if this is for a specific post type outside the loop)

global $post;
if ( $post->post_type == 'my_post_type' // checks the post type of the post
     && is_single() // Checks if this is a single post
     && has_term( 'term-name or id or slug', 'my_taxonomy', $post->ID ) // Check if post has specific term
) {
    // Do something if our condition is true
}

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories?

As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts the term as first parameter and the taxonomy name as second parameter. So your condition should look like this: (if this is for a specific post type outside the loop)

global $post;
if ( $post->post_type == 'my_post_type' // checks the post type of the post
     && is_single() // Checks if this is a single post
     && has_term( 'term-name or id or slug', 'my_taxonomy', $post->ID ) // Check if post has specific term
) {
    // Do something if our condition is true
}

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories?

As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts the term as first parameter and the taxonomy name as second parameter. So your condition should look like this: (if this is for a specific post type outside the loop)

global $post;
if ( $post->post_type == 'my_post_type' // checks the post type of the post
     && is_single() // Checks if this is a single post
     && has_term( 'term-name or id or slug', 'my_taxonomy', $post->ID ) // Check if post has specific term
) {
    // Do something if our condition is true
}
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories?

As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts the term as first parameter and the taxonomy name as second parameter. So your condition should look like this: (if this is for a specific post type outside the loop)

global $post;
if ( $post->post_type == 'my_post_type' // checks the post type of the post
     && is_single() // Checks if this is a single post
     && has_term( 'term-name or id or slug', 'my_taxonomy', $post->ID ) // Check if post has specific term
) {
    // Do something if our condition is true
}