Sorting does not work

This topic contains 12 replies, has 4 voices, and was last updated by  Stiofan O’Connor 9 years, 6 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #62978

    Itamar Peretz
    Free User
    Post count: 9

    Hey,
    there are three issues im facing regarding the sorting option on my website :
    1- The sorting does not seem to work – alphabetical sorting does not change the order of the posts
    2- After picking a sorting filter, for example, alphabetical, the select box does not chagne and point to alphabetical as expected.
    3- After sorting, the list of posts that are shown after moving to next available posts is duplicated.

    My website address is https://www.secrettelaviv.com/best/ and i’d really appreciate if you’ll be able to determine what cause the problems above, which are critical for our project at the moment.

    Thanks in advance,
    Itamar

    #62990

    Guust
    Moderator
    Post count: 29970

    That seems to be the result of the way you have customized your listings display.
    Does everything work fine if you disable that customization?

    #63067

    Itamar Peretz
    Free User
    Post count: 9

    The customization only deals with the way posts are disaplyed, i.e – html and css, the sorting query results should not be influenced at all.
    Can you please point me to the function that is responsible for pulling the sorting results?

    Thanks in advance.

    #63074

    Itamar Peretz
    Free User
    Post count: 9

    In listing_filters.php, geodir_posts_orderby function, there’s a variable named $sort_by.
    I’ve dumped it into screen, and no matter what sort parameter I choose, it’s value remains “string(30) “geodir_special_offers_text_asc” – and I believe that’s the problem.

    I’d be grateful if you guys have any idea why it happens.

    #63090

    Paolo
    Site Admin
    Post count: 31211

    Hi,

    please provide admin credentials and FTP details and I’ll ask to one of the developers to debug it.

    Let us know,

    Thanks

    #63587

    Itamar Peretz
    Free User
    Post count: 9
    This reply has been marked as private.
    #63597

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I have done some debugging, the sort by value remains correct but the filter “geodir_posts_order_by_sort” is filtering the value, have u added a filter for this somewhere, this is all i can think would change it.

    Stiofan

    #63599

    Itamar Peretz
    Free User
    Post count: 9

    Stiofan, thanks for the reply.
    I think the source of the problem is different –
    the $_REQUEST array is empty on the geodir_posts_orderby function in listing_filters.php .
    Because it’s empty, the following flow will always skip the first condition and execute the second :

    if (isset($_REQUEST[‘sort_by’]) && $_REQUEST[‘sort_by’] != ” && is_main_query())
    $sort_by = esc_attr($_REQUEST[‘sort_by’]);

    if ($sort_by == ”) {
    $default_sort = geodir_get_posts_default_sort($geodir_post_type);
    if (!empty($default_sort))
    $sort_by = $default_sort;
    }

    And that’s the reason why $sort_by is always equal to $default_sort.

    Do you have any idea why would the $_REQUEST array be empty ?

    #63606

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    The request is only empty if there is not sort order selected, i tested code on your site in that exact section, feel free to add it back

    
    
    if (isset($_REQUEST[‘sort_by’]) && $_REQUEST[‘sort_by’] != ” && is_main_query())
    $sort_by = esc_attr($_REQUEST[‘sort_by’]);
    
    echo '###'.$sort_by;
    
    if ($sort_by == ”) {
    $default_sort = geodir_get_posts_default_sort($geodir_post_type);
    if (!empty($default_sort))
    $sort_by = $default_sort;
    }

    Stiofan

    #63607

    Itamar Peretz
    Free User
    Post count: 9

    Hey, once again thanks for the quick reply.

    I’m afraid you are wrong – I’ve chosen a sorting order and still the request array is empty.
    A print screen with that shows the url with chosen sort type and the empty $sort_by value using your code is attached.

    Thank you.

    #63651

    Itamar Peretz
    Free User
    Post count: 9
    This reply has been marked as private.
    #63767

    Itamar Peretz
    Free User
    Post count: 9

    Hey,
    we’ve got it working.

    Thanks for helping, we truly appreciate it.

    #63769

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    OK i think we were checking different url’s

    https://www.secrettelaviv.com/best/health-and-beauty/?sort_by=overall_rating_asc Shows the code but :https://www.secrettelaviv.com/best/?sort_by=overall_rating_asc does not

    I tried doing i print_r($_REQUEST); in the very first active pluign which is the very first code loaded after core WP and it is blank, so unless you have edited core WP i would say its server related…

    Stiofan

Viewing 13 posts - 1 through 13 (of 13 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