Last active
December 19, 2015 10:29
-
-
Save robneu/5940779 to your computer and use it in GitHub Desktop.
Reverse the post order for the Genesis Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'pre_get_posts', 'prefix_reverse_post_order' ); | |
/** | |
* Reverse Post Order for Post Archives | |
* on the Genesis Framework | |
* | |
* @author FAT Media | |
* @link http://youneedfat.com/reverse-post-order-genesis-framework/ | |
* @param object $query data | |
* | |
*/ | |
function prefix_reverse_post_order( $query ) { | |
if ( is_admin() ) | |
return; | |
// Only change the query for post archives. | |
if ( $query->is_main_query() && is_archive() && ! is_post_type_archive() ) { | |
$query->set( 'orderby', 'date' ); | |
$query->set( 'order', 'ASC' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can check out a full breakdown and explanation of this Gist on our blog: http://youneedfat.com/reverse-post-order-genesis-framework/