Order by rand only
-
I want to update the main query and taxonomy queries so they show the results randomly
function func_custom_order( $qry ) { if ( $qry->is_main_query() && $qry->is_tax() ) { $qry->set( 'orderby', 'rand' ); } } add_action( 'pre_get_posts', 'func_custom_order' );
Without this in functions.php, the ordering is;
ORDER BY wp_posts.menu_order, wpsc_posts.post_date DESC
With this;
ORDER BY wp_posts.menu_order, RAND()
Can I have it just order by rand, and not also menu_order?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Order by rand only’ is closed to new replies.