Reverse loop order.
-
I realize this has been asked before. 4 years ago, in fact: https://ww.wp.xz.cn/support/topic/reverse-loop-order.
However I think the answer was extremely unsatisfactory, and unfortunately that thread has been closed.
Of course I’ve looked up the documentation for WP_Query, however there doesn’t seem to be an option to invert the loop order (‘order’ reverses the query order, but this doesn’t play well with ‘posts_per_page’; I want to reverse the result set, not the query itself. Reversing the query results in a different result set).
I’m aware this may require the query results to be fully fetched from the database server before reordering, but is there a way to do that without having to throw away The Loop interface? I don’t want to have to modify all my templates just to have them using my reversed posts array instead of the_title(), the_content(), etc.
Is there a way around that? Can I insert a custom array back into The Loop, for example? Or is there some other way of reversing the result set in the WordPress way?
The topic ‘Reverse loop order.’ is closed to new replies.