Created
September 7, 2014 21:41
-
-
Save ChrisLTD/28843a642766c78fb142 to your computer and use it in GitHub Desktop.
Sort wordpress categories by description field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$resource_terms = get_terms( 'section' ); | |
// Sort terms by description field | |
function description_compare($a, $b) { | |
return $a->description - $b->description; | |
} | |
usort($resource_terms, "description_compare"); | |
?> | |
<div class="resource-filter"> | |
<a href="#" class="resource-filter-term" data-filter="article" data-filter-by=".resource">All</a> | |
<?php foreach( $resource_terms as $term ): ?> | |
<a href="#" class="resource-filter-term" data-filter="article" data-filter-by=".<?php echo $term->slug ?>"><?php echo $term->name ?></a> | |
<?php endforeach; ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment