Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 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.             echo '<pre>',print_r($term,1),'</pre>';
  9.             $term_id = $term->term_id;
  10.             $term_name = $term->name;
  11.             $kgs_allterms_array[] = $term_name;
  12.             if ($term_id == $kgs_primaryterm) {
  13.                 array_unshift($kgs_allterms_array, $term_name);
  14.             }
  15.         }
  16.         $kgs_sortedterms_array = array_unique($kgs_allterms_array);
  17.         foreach($kgs_sortedterms_array as $sortedterm) {
  18.             echo ' <span>' . $sortedterm . '</span> ';
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement