Change GeoDirectory random sorting

Random sorts reset every 24 hours to save serverresources.

Try the following Code Snippet to refresh every hour or modify it as you like

Random resets every 24 hours to save resources

Try the following Code Snippet to refresh every hour or modify it as you like

function gd_snippet_rand_seed( $rand_seed ) {
	$minutes = 60; // SET MINUTES HERE

	$transient_name = 'geodir_rand_seed_custom_' . $minutes;
	$rand_seed = get_transient( $transient_name );

	// If we don't have a transient then set a new one
	if ( ! $rand_seed ) {
		$rand_seed = time();
		set_transient( $transient_name , $rand_seed, (int) $minutes * MINUTE_IN_SECONDS ); /* Updated after every x minutes */
	}

	// validate
	$rand_seed = absint( $rand_seed );

	return $rand_seed;
}
add_filter( 'geodir_rand_seed', 'gd_snippet_rand_seed' );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us