top of page

Alphabetically Sort Terms of Taxonomy

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Jun 11, 2021
  • 1 min read



<?php 

	function cmp($a, $b){
        return strcmp($a->slug, $b->slug);
    }

	$terms = get_terms([
			    'taxonomy' 		=> 'product_brand',
			    'hide_empty' 	=> false,
			    'orderby' 		=> 'name',
				'order' 		=> 'ASC' 
			]);


    usort($terms, "cmp");

	foreach($terms as $term){
?>
	<li>
		<input type="radio" id="<?php echo $term->slug; ?>" name="brand" value="<?php echo $term->slug; ?>"
			class="prdfilter">
		<label for="<?php echo $term->slug; ?>"><?php echo $term->name; ?></label>
	</li>
<?php } ?>',
												    'hide_empty' 	=> false,
												    'orderby' 		=> 'name',
    												'order' 		=> 'ASC' 
												]);

									
									    usort($terms, "cmp");

										foreach($terms as $term){
									?>
										<li>
											<input type="radio" id="<?php echo $term->slug; ?>" name="brand" value="<?php echo $term->slug; ?>"
												class="prdfilter">
											<label for="<?php echo $term->slug; ?>"><?php echo $term->name; ?></label>
										</li>
									<?php } ?>


 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page