Some help with a listing display shortcode

This topic contains 1 reply, has 2 voices, and was last updated by  Alex Rollin 5 years, 5 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #490401

    Stephen Nipperess
    Expired Member
    Post count: 9

    I am using the following short code to display 6 listings on my website frontpage, in two rows of three. Ramdomly displayed and chosen from listings that have the tag “Deals Under $100″. It seems to mostly work. I am getting 6 listings on two rows of three but they are not being chosen and displayed randomly on every page refresh. It worked when I was using geodirectory v1 but not with v2.
    Here is the shortcode I am using
    [gd_listings post_type=”gd_place” layout=”3″ post_limit=”6″ tags=”Deals Under $100″ with_pagination=”0″ list_sort=”random”]

    #490403

    Alex Rollin
    Moderator
    Post count: 27815

    GDV2 does ‘random’ a bit differently. A random sort order is applied for 24 hours, then resorted again. You can change the 24 hour interval to something different with this code snippet.

    
    
    
    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;
    }
    

    How to use code snippets: https://wpgeodirectory.com/docs-v2/faq/customizing/#custom-code

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount