Random display of listings

This topic contains 8 replies, has 4 voices, and was last updated by  Pete Williams 5 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #467121

    Pete Williams
    Full Member
    Post count: 34

    Hi guys,

    Although I’ve selected ‘random’ for the ordering of displayed listings, they appear in the same order, regardless of browser or device, even after clearing the cache

    I can’t work out any pattern to the order they are presented, it seems to have selected an order and sticks with it

    Any ideas?

    #467137

    Guust
    Moderator
    Post count: 29970

    Please post URL and WP admin details in a private reply so we can have a look at your settings.
    Include the URL of the page you are referring to.

    Thanks

    #467152

    Pete Williams
    Full Member
    Post count: 34
    This reply has been marked as private.
    #467159

    Guust
    Moderator
    Post count: 29970

    Random order is locked in for 24 hours, otherwise if you go to the next page, there is a chance the same listing comes up again as you just saw on the first page.

    Thanks

    #467161

    Pete Williams
    Full Member
    Post count: 34

    Right, I understand now, thanks

    Is it possible to change the ‘locked in’ time at my level, or is it fixed with the master plugin?

    #467205

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Pete,

    The 24 hour thing is fixed in the plugin but the seed is filterable, the below example would change that to 4 hours (not tested):

    
    
    add_filter('geodir_rand_seed','_my_geodir_rand_seed'); 
    function _my_geodir_rand_seed($rand_seed){
    $rand_seed = get_transient( 'geodir_rand_seed_custom' );
    
    		// if we don't have a transient then set a new one
    		if(!$rand_seed){
    			$rand_seed = time();
    			set_transient( 'geodir_rand_seed_custom', $rand_seed, 4 * HOUR_IN_SECONDS );
    		}
    
    		// validate
    		$rand_seed = absint($rand_seed);
    
        return $rand_seed;
    }

    Stiofan

    #467206

    Pete Williams
    Full Member
    Post count: 34

    Great, thanks Stiofan, I’ll give it a try…

    Could you direct me to where/ which file that code needs to be applied please?

    #467220

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    Code snippets should only be applied using the code snippets plugin so that are never overwritten by updates.

    Thanks

    #467435

    Pete Williams
    Full Member
    Post count: 34

    Thanks Paolo, I think it’s working 🙂

    Much appreciated!

    Pete

Viewing 9 posts - 1 through 9 (of 9 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket