Changing Projects Order

Is there an easy way to change the order of my Projects… maybe even a shuffle of some kind so I can mix up the display links on the front page each day, or at least once in a while without having to go into each page and changes dates or something.

If there is a way the site will work like a phone app were returning people will see a different order of whats available each time.

I’m getting crazy hits daily (1000+!) on it and it is just a local virtual garage sale.

Hello there,

Thank you for asking.

I thought that objective can be achieved by modifying the current projects query using pre_get_posts hook. Then set random query order.

Try to add the following function into the child theme’s functions.php file.

add_action( 'pre_get_posts', 'prefix_random_projects_query' );

function prefix_random_projects_query( $query ) {

	$q_vars = $query->query_vars;

	if( ! is_admin() && isset($q_vars['post_type']) && $q_vars['post_type'] == 'projects' ){
		$query->set('orderby', 'rand');
	}

}

Let me know how it works.

Regards,
Kharis