• 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.