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-
AuthorPosts
-
December 8, 2015 at 8:29 pm #62978
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,
ItamarDecember 8, 2015 at 9:45 pm #62990That seems to be the result of the way you have customized your listings display.
Does everything work fine if you disable that customization?December 9, 2015 at 5:33 pm #63067The 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.
December 9, 2015 at 5:49 pm #63074In 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.
December 9, 2015 at 6:17 pm #63090Hi,
please provide admin credentials and FTP details and I’ll ask to one of the developers to debug it.
Let us know,
Thanks
December 12, 2015 at 5:01 pm #63587This reply has been marked as private.December 12, 2015 at 6:01 pm #63597I 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
December 12, 2015 at 6:13 pm #63599Stiofan, 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 ?
December 12, 2015 at 6:31 pm #63606The 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
December 12, 2015 at 6:40 pm #63607Hey, 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.
December 13, 2015 at 7:28 pm #63651This reply has been marked as private.December 14, 2015 at 6:50 pm #63767Hey,
we’ve got it working.Thanks for helping, we truly appreciate it.
December 14, 2015 at 7:01 pm #63769OK 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
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket