Support » Fixing WordPress » Custom taxonomy – sorting by something other than alphabetically

  • Hi

    I’m building a real estate website and I’m using custom taxonomy for property features. The features fall into three ‘categories’ which are displayed in three columns on the property details page. Each colum/’category’ has the relevant features for that property. Below is how I am getting it to display on the single_listing page.

    $arr_terms = get_the_terms($post->ID, 'property_features');
    if ($arr_terms) {
    
    		echo "<div id='featurecategories'>";
    		if ($arr_terms) {
    
    		foreach ($arr_terms as $item) {
    			if($item->parent == 0) {
    			$cat_id = $item->term_id;
    			echo "<div class='featuresblock'>";
    			echo "<h4>". $item->name . "</h4>";
    
    			echo "<ul>";
    			foreach ($arr_terms as $item2) {
    
    				if($item2->parent == $cat_id) {
    				 echo "<li><a href='". get_term_link($item2, 'property_features') ."'>". $item2->name . "</a></li>";
    				}
    
    			}
    			echo "</ul>";
    			echo "</div>";
    			}
    		}
    		}
    		echo "</div>";
    
    }

    The problem is that this displays everything alphabetically, and I want to sort it in my own order. One way I thought would be to number the slugs, and then sort it by them. Does anyone know how I would amend the above code so that it displays the same content but sorted by slug?

    Or if there is another way to achieve the same, I’d be happy to use that.

    Thanks in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom taxonomy – sorting by something other than alphabetically’ is closed to new replies.