Title: Custom Field value sorting
Last modified: August 19, 2016

---

# Custom Field value sorting

 *  [line47](https://wordpress.org/support/users/line47/)
 * (@line47)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/custom-field-value-sorting/)
 * Hello and thanks for looking into my post!
 * I have a bunch of values for the same custom field name.
    I would like to display
   the custom fields in ascending alphabetical order. Right now they are showing
   in the order I entered them. Any ideas?
 * Custom fields
    name – purchase, value – purchase-itunes name – purchase, value–
   purchase-amazon name – purchase, value – purchase-emusic
 * here is the code I am using:
 *     ```
       <?php $value = get_post_meta($post->ID, 'purchase', false); ?>
   
       	<ul class="purchaseLinks">
       		<?php foreach($value as $value) {
       			if($value == 'purchase-itunes') {
       		echo '<li><a href="#">itunes (Mp3)</a></li>';
       	}
       	elseif($value == 'purchase-amazon') {
       		echo '<li><a href="#">Amazon (Mp3)</a></li>';
       	} 
   
       	elseif($value == 'purchase-emusic') {
       		echo '<li><a href="#">emusic (Mp3)</a></li>';
       	}
   
       else {
       		echo '';
       	}
   
       			} ?>
       	</ul>
       ```
   

The topic ‘Custom Field value sorting’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [line47](https://wordpress.org/support/users/line47/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/custom-field-value-sorting/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
