I have the following code which works exactly as i'd like it to, but the displayed tags are in reverse alphabetical order and i'm not sure how to sort. I've noticed that the_tags has an argument called "order" that allows ordering, but get_the_tags does not. Is this because i stored the tags (when adding them with wordpress admin area) in the order that they are being displayed in? CAn i not sort them when calling the array? I'd hate to have to delete the 3 tags and re-add them in order, as this is not very flexible should i want to add another tag in the future that begins with "A", for example. Does that makes sense? :D
<?php
$post_tags = get_the_tags();
if (is_array($post_tags) || is_object($post_tags)) {
foreach( $post_tags as $tag) :
if ( $tag->name === 'Nut Free' ) :
?>
<span title="Nut Free!" class="post-inline-tag nut-free">NF</span>
<?php
elseif ( $tag->name === 'Gluten Free' ) :
?>
<span title="Gluten Free!" class="post-inline-tag gluten-free">GF</span>
<?php
elseif ( $tag->name === 'Soya Free' ) :
?>
<span title="Soya Free!" class="post-inline-tag soya-free">SF</span>
<?php
else :
// Post has neither tag, do nothing.
endif;
endforeach;
}
?>