Set random order for listings by default

Hi.

I was searching for a solution to get a random order of listings in the searchresults and on tags/regions.

I stumbled upon this thread Change order of listings to random

add_action(
	'pre_get_posts',
	function($query){
		if(!is_admin() && 'hp_listing' === $query->get('post_type') && 'listings_view_page' === hivepress()->router->get_current_route_name()) {
			$query->set('orderby', 'rand');
		}
	},
	1000
);

But it seems like that this function is breaking the single listing-pages.

Usually it should look like this one: Ferien- & Pferdehof | Angelurlaub.de

Any idea?

Okay, problem solved. Just saw your post here: Change order of listings to random

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.