ディレクトリスタッフのリストに取り組んでいます。この目的のためのプラグインは、私が探していたものに対して複雑すぎるか単純すぎるため、カスタムソリューションに行きました. そこで、このカスタム投稿タイプ「staff」を作成し、カスタム分類法 (科学、数学、管理など) も添付して、テーブルにリストされたすべての投稿を取得するクエリを作成しました。私のコードは次のようになります。
<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>
このリストは非常にうまく機能していますが、クライアントからアルファベット インデックスの追加を依頼されました。したがって、結果の前にリストされた範囲 az が必要になり、クリックすると、「staff_last_name」カスタム フィールド (ACF を使用しています) が選択した文字で始まる投稿のみが表示されます。
AZIndex、WP-Snap などのプラグインを試してみましたが、どれもうまくいきませんでした。
この件に関する推奨事項/解決策をいただければ幸いです。