Hi
It doesn’t happen often but in this case I think Michael’s solution does not address what you want to do. I use that plugin on sites myself and was not aware it would present custom fields in any sorted order. I tested and was not able to get it to do so.
the_meta returns an array of arrays, so what is needed is to sort the array of key values before displaying the output. I looked up the code for the_meta() and added an array sort statement. Perhaps someone more knowledgeable in WP actions/filters can explain how to do it through overriding the built-in the_meta(). In the meantime this code did what you are looking for when I tested it.
I set it up as a function – put this in your theme’s functions.php file and use <?php my_meta(); ?> in your theme template where you want its output to appear
function my_meta() {
if ( $keys = get_post_custom_keys() ) {
echo "<ul class='post-meta'>\n";
asort($keys);
foreach ( (array) $keys as $key ) {
$keyt = trim($key);
if ( '_' == $keyt{0} )
continue;
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
}
echo "</ul>\n";
}
}
I wanted to ask you, by the way, why you are using custom fields for your definitions rather than just listing this as content in your post? That would be much simpler, and you could manually sort them as you add new definitions.
HTML has a list structure specifically for key word – definition pairs – Definition List <dl>
https://www.w3schools.com/TAGS/tag_dl.asp
You could insert these tags in the WP HTML edit tab and style them in the CSS.