Skip to content

Instantly share code, notes, and snippets.

@jdelia
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelia/8cf484ef31e2337052e4 to your computer and use it in GitHub Desktop.
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
<?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