I'm working on a directory staff listing. I went to a custom solution because plugins for this purpose were too complex or too simple for what I was looking for. So I created this custom post type "staff" with custom taxonomies attached as well to it(Science, Mathematics, Administration, etc) so I have a query where I get all those posts listed in a table, my code looks as follows.
<table class="directorytable">
<thead>
<th class="first-th">Portrait</th>
<th>Name</th>
<th>Position</th>
<th>Phone</th>
<th style="width:60px !important;text-align:center;">Email </th>
<th style="width:60px !important;text-align:center;">Website </th>
<th style="width:60px !important;text-align:center;">Details </th>
</thead>
<?php query_posts(array('post_type'=>'staff','orderby'=>'meta_value','meta_key'=>'staff_last_name','order'=>'asc'))?>
<?php while(have_posts()): the_post();?>
<tr>
<td class="first-td"><a rel="lightbox" href="<?php the_permalink(); ?>"/><img src="<?php the_field('staff_portrait');?>" style="border-radius:2px; width:35px;"/></a></td>
<td><a rel="lightbox[1]" href="<?php the_permalink();?>"><?php the_field('staff_name');?> <?php the_field('staff_last_name');?></a> </td>
<td><?php the_field('staff_position'); ?></td>
<td><?php the_field('staff_phone');?> | <strong>Ext: </strong><?php the_field('staff_extension')?></td>
<td style="width:60px; text-align:center;"><a href="mailto:<?php the_field('staff_email');?>"><img src="/images/directory/mail.png"/></a></td>
<td style="width:60px; text-align:center;"><?php if(get_post_meta($post->ID,'staff_website', true)){?><a target="_blank" href="<?php the_field('staff_website');?>"><img src="/images/directory/document-globe.png"/></a><?php } else {?><?php echo '';?><?php } ?></td>
<td style="width:60px; text-align:center;"><a rel="lightbox[2]" href="<?php the_permalink();?>"><img src="/images/directory/magnifier-zoom.png"/></a></td>
</tr>
<?php endwhile; ?>
</table>
So this list is working very nicely, but my client requested me to add an alphabet index. So I will need a range a-z listed before results and then on clicking, show only the posts that their "staff_last_name" custom field (I'm using ACF) begins with the chosen letter.
I have tried with some plugins like AZIndex, WP-Snap, etc, but none of those worked for me.
I'd appreciate any recommendation / solution for this matter.