Hi, in my site I have custom post type. I’m trying to get the loop of custom post types to display in alphabetical order, but having no luck. I’ve tried various plugins and other solutions, but most only allow manual sorting 🙁
Any help appreciated.
What is your custom post type name? Can you add more information, please!
You should add something like this in your code:
$args = array(
'post_type' => 'book',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
Or like this:
$args = array( 'post_type' => 'book', 'posts_per_page'=>5, 'orderby'=>'title','order'=>'ASC');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
Remember you must using order and orderby in your arguments.
Your email address will not be published. Required fields are marked *