I can't find answer to my question, just hope you will find it relevant.
I'm working a magazine website and I need to display names of contributors in a list by family names. The contributors have been created by a custom taxonomy. Some of those names have more than one First names.
Example
S
Jane Gabriella Maria Sanchez
John Smith
So what I did is that I created a custom field for the family name. It works and put them in the right order. Here's my code the I created with the help of some resource here. The only thing I would like to be able to do now is to query only by the first letter of the get_field('family_name', $term). To been able to group them on my page. A, B, C, D.....
<?php
$terms = get_terms('contributors');
$args = array('contributors' => $term->slug);
$query = new WP_Query( $args );
$order_terms = array();
foreach( $terms as $term ) {
$position = get_field('family_name', $term);
$order_terms[$position] ='<li><a href="'. get_bloginfo( 'url' ) . '/contributors/' . $term->slug . '">'.$term->name.'</a></li>';
}
ksort($order_terms);
foreach( $order_terms as $order_term ) {
echo $order_term;
}
?>
Maybe it's not possible, let me know.
Thanks in advance.