CPTs repeating on listings pages with random sorting

This topic contains 7 replies, has 3 voices, and was last updated by  Kiran 4 years, 7 months ago.

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

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #511915

    Mike Stevens
    Full Member
    Post count: 17

    Hi

    I can’t get the sorting to work right … I just have 2 fields that I want to sort by:

    package_id (so that sponsored listings come first – this works)
    random
    Random (the field name is [post_status], which I don’t understand – but this does not work. Listings are repeated on subsequent listings pages)

    Check this – and make sure to look at pages 2 an 3:

    https://insightplatforms.com/platforms/category/statistics-data-science-solutions/

    There are repeated listings, which isn’t helpful.

    Any ideas how to fix?

    Many thanks

    #511955

    Alex Rollin
    Moderator
    Post count: 27815

    This is a known issue with sorting by package ID. We are looking into it. Please provide WP Admin and FTP so we can look into your case and apply a fix.

    Thanks

    WordPress Credentials
    WP Admin Login URL:
    WP Admin Username:
    WP Admin Password:

    FTP Credentials
    FTP Host:
    FTP Port:
    FTP User:
    FTP Password:

    #512006

    Mike Stevens
    Full Member
    Post count: 17
    This reply has been marked as private.
    #512066

    Kiran
    Moderator
    Post count: 7069

    Hi Mike,

    I checked and found SQL query results changes the listings order among same package id.

    I have added “Post Date” as a second level sorting under package id at Platforms > Settings > Sorting > Package Id > Post Date.

    Please check and let us know.

    Thanks,
    Kiran

    #512067

    Mike Stevens
    Full Member
    Post count: 17

    Hi – this seems to have stopped the listings repeating on subsequent pages, but I don’t want them to sort in post date. I want package first, so that sponsored listings come top, and then randomly sorted after that. I thought GD could do that? Thanks

    #512069

    Kiran
    Moderator
    Post count: 7069

    Hi Mike,

    It already doing that. It sorts first with package id and then applies 2nd level sorting within listing with same package id.

    Example:
    Listing A has package id = 1 & post date = 2019-10-07
    Listing B has package id = 3 & post date = 2019-10-05
    Listing C has package id = 1 & post date = 2019-10-02
    Listing D has package id = 2 & post date = 2019-09-30
    Listing E has package id = 6 & post date = 2019-09-30
    Listing F has package id = 6 & post date = 2019-10-01

    It will sort results in following order:
    Listing F
    Listing E
    Listing B
    Listing D
    Listing A
    Listing C

    For Random(post_status) it will use random order.

    Let us know.

    Kiran

    #512070

    Mike Stevens
    Full Member
    Post count: 17

    Hi

    I’m sorry, I don’t understand. The sort order is not random – it is sorting by date. How do I get it to sort randomly AFTER sorting on package_id?

    Thanks

    #512074

    Kiran
    Moderator
    Post count: 7069

    Hi Mike,

    If you need random order within same package id then use following PHP snippet. It will first use package id sorting and then random.

    
    
    /**
     * Set random sorting.
     */
    function gd_snippet_191008_random_sorting( $orderby, $sort_by, $table ) {
    	if ( $sort_by == 'package_id_asc' || $sort_by == 'package_id_desc' ) {
    		$orderby .= ", RAND()";
    	}
    	return $orderby;
    }
    add_filter( 'geodir_posts_order_by_sort', 'gd_snippet_191008_random_sorting', 1000, 3 );

    Kiran

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

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

Open Support Ticket