has_term or in_category for Custom Post Types

has_term() need third parameter to specify which post type have this term. So, your code would be

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

Beside that approach, you can use following

global $post; 
if (    ( $post->post_type == 'property' ) 
     && has_term( 'sold', 'category' )
) { ?>
    <div class="sold_prop_note">
        <h3>This Property is sold. Take a look at our current exclusives! <a href="https://wordpress.stackexchange.com/properties">View Exclusives</a></h3>
      </div>
<?php }

Leave a Comment