Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. function display_property_taxonomy_terms($post_id) {
  2.     $property_terms = get_the_terms($post_id,'listing_type');
  3.     if($property_terms){
  4.         $kgs_primaryterm = get_post_meta(get_the_id(), '_yoast_wpseo_primary_listing_type', true);
  5.         $kgs_allterms_array = array();
  6.         $kgs_sortedterms_array = array();
  7.         foreach($property_terms as $term) {
  8.             $term_id = $term->term_id;
  9.             $term_name = $term->name;
  10.             $kgs_allterms_array[] = $term_name;
  11.             if ($term_id == $kgs_primaryterm) {
  12.                 array_unshift($kgs_allterms_array, $term_name);
  13.             }
  14.         }
  15.         $kgs_sortedterms_array = array_unique($kgs_allterms_array);
  16.         foreach($kgs_sortedterms_array as $sortedterm) {
  17.             echo ' <span>' . $sortedterm . '</span> ';
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement