Last active
August 29, 2015 14:22
-
-
Save jdelia/8cf484ef31e2337052e4 to your computer and use it in GitHub Desktop.
Genesis Agent Profiles Archive Page - Sort Randomly and Show Up to 999 agents per page
This file contains 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 | |
//* Do NOT include the opening php tag | |
// Force Sorting on the archive profiles page defaults to random up to 999 per page. | |
add_action( 'pre_get_posts', 'aeprofiles_change_sort_order_extended_custom', 20 ); | |
function aeprofiles_change_sort_order_extended_custom( $query ) { | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'aeprofiles' ) || is_tax() ) { | |
$query->set( 'orderby', 'rand' ); | |
$query->set( 'order', 'ASC' ); | |
$query->set( 'paged', $paged ); | |
$query->set( 'posts_per_page', '999' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment