Reverse the Post Order on the Genesis Framework

Reverse Post Order on the Genesis Framework

If you’ve ever wanted to reverse the post order on your Genesis powered website, there are a number of ways you could do it. My friend Jonathan Perez posted a method which I don’t recommend for a number of reasons.

The simplest way to reverse the post order on the Genesis Framework, or any WordPress-powered website for that matter, is to use a helpful function called pre_get_posts. The ubiquitous Bill Erickson has a detailed post about how you can use pre_get_posts to do all kinds of neat stuff besides changing the post order.

If all you’d like to do is reverse the posts for post archives on your Genesis website, you can paste this directly into your functions.php file:

Reverse the Post Order on All Standard Genesis Post Archives:

You could easily modify this code to reverse the post order in other situations. For example, you could reverse the post order for only custom post type archives, or only a particular category archive.

Hold Up, What About The Blog Page Template?!

If you use the Genesis blog page template on your site, you’ll need to add an extra bit of code to functions.php to reverse the post order. According to Bill, it’s probably not such a good idea to use it anyway.

If you’re dead set on using the Genesis blog page template for some reason, here’s how I would reverse the post order:

Reverse the Post Order on the Genesis Blog Page Template:

In my opinion, using pre_get_posts is a much more efficient and modular approach than the one published by Jonathan. If you disagree or have a better way to accomplish this, let me know in the comments and I’ll update my code!