I'm developing a wordpress website with custom posts which are ordered alphabetically in the loop.
<!-- THE ARGS -->
<?php global $query_string;
$args = wp_parse_args($query_string);
$args = array(
'post_type' => 'custom_post',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
); ?>
<!-- THE LOOP -->
<?php $wp_query = new WP_Query( $args ); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Nothing fancy there, just a normal loop.
When I open a post, in its page I have the usual previous_post_link and next_post_link so I can navigate through posts. However, this is done by chronological order of the posts, and I wish to do so by the same alphabetical order as I used in the loop, of course. Any help on this matter would be very appreciated. Thanks in advance!
It looks like this plug-in does what you're after, e.g.:
<ul class="pager">
<?php previous_post_link_plus( array('order_by' => 'post_title') ); ?>
<?php next_post_link_plus( array('order_by' => 'post_title') ); ?>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With