If you’re working with the post type’s archive location that gets created when “has archive” is true, then you’ll need to tap into the pre_get_posts filter to change how the sort order is.
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
If you’re doing a custom WP_Query somewhere, you can set the sort order parameters as part of your arguments.
https://codex.wordpress.org/Class_Reference/WP_Query
Thread Starter
gfaw
(@gfaw)
Thanks Michael!
Meanwhile I’ve figured that out myself.
Main issue had been the page navigation – the buttons, as the default WP logic is diametrially opposite to conventional logic (that is, first comes first and last comes last).
In that way I swapped the buttons over, making the PREV-button a NEXT-button and vice versa:
Original code:
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav class="post-nav">
<ul class="pager">
<li class="previous"><?php next_posts_link(__('← Back', 'roots')); ?></li>
<li class="next"><?php previous_posts_link(__('Forward →', 'roots')); ?></li>
</ul>
</nav>
<?php endif; ?>
My code:
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav class="post-nav">
<ul class="pager">
<li class="previous"><?php previous_posts_link(__('← Back', 'roots')); ?></li>
<li class="next"><?php next_posts_link(__('Forward →', 'roots')); ?></li>
</ul>
</nav>
<?php endif; ?>
Basically my first approach was way too complicated until it dawned on me. Not a plugin issue though, but somebody might find it helpful.
Yeah, those pagination functions always take a moment to work out to get the logic for.