has_term or in_category for Custom Post Types

Question

I have property as a custom post type. I want to display a specific message if the property is in the sold category. To do that, I’m using the function below:

if ( has_term('sold', 'category')) {
  ?>
  <div class="sold_prop_note">
    <h3>This Property is sold. Take a look at our current exclusives! <a href="/properties">View Exclusives</a></h3>
  </div>
  <?
}

Before using the above, I also tried in_category like the one below:

if ( in_category( array( 'sold', 'homepage-sold' ) )) {
  ?>
  <div class="sold_prop_note">
    <h3>This Property is sold. Take a look at our current exclusives! <a href="/properties">View Exclusives</a></h3>
  </div>
  <?
}

Both of the haven’t worked. To add the Custom Post Type, the taxonomies were with 'taxonomies' => array( 'category', 'post_tag' ).

Both are being used inside the loop (via a shortcode). Am I missing something?

0
, RaajTram 5 years 2016-05-21T17:20:40-05:00 0 Answers 66 views 0

Leave an answer

Browse
Browse