- Post type archive that lists posts in alphabetical order.
- Filter posts by letter or symbol.
- PHP >= 8.1
- WordPress >= 5.8
Set the alpha_sort
support for your post type.
register_post_type( 'post_type_name', [
...,
'supports' => [ 'title', 'editor', 'thumbnail', 'alpha_sort' ],
...
] );
Or
add_post_type_support( 'post_type_name', 'alpha_sort' );
To show the filters on the post type archive page use the following code in your theme template file.
ICIT\StandFirst\PostSort\AtoZ::post_type_alpha_filters( 'post_type_name', [ 'title'=> 'Filters', 'all_title' => 'All Posts' ] );