Sorting for Listing
This topic contains 11 replies, has 6 voices, and was last updated by Paolo 10 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: sorting
-
AuthorPosts
-
June 30, 2014 at 6:12 am #6752
Hi,
I am looking to realize the sorting we need for our finder but I cant figure it out. For us there are two important groups which need to be sorted. First the Featured customers (paid account) and then the free entries. I would like to sort first always the featured customers alphabetically and after them there should be the free listings also alphabetically.
Example:
Anna (feat)
Bert (feat)
Chris (feat)
Tony (feat)
Albert (non feat – free)
Steve (non feat – free)
Tammy (non feat – free)Can you please tell me how todo this?
Thanks guys!
PSIJune 30, 2014 at 6:51 am #6757Have you tried the GD options for “Place”/”Sorting Options” tab
See attached image
June 30, 2014 at 10:30 am #6778Yes I have tried but it seems to be that it is only possible to have one or the other option not both like I need it. I dont want to give the visitior the possibility to switch filters.
Featured items have always to be listed on top…
I hope this describes my problem
June 30, 2014 at 1:59 pm #6810I haven’t experimented with these settings but I thought they way shown in the image would achieve what you want?
I’m sure Paolo or Vikas will help.
June 30, 2014 at 7:26 pm #6854That is currently not possible. You can sort by featured or alphabetically.
ThxJuly 1, 2014 at 6:14 am #6932Hi Paolo,
Thank you for your reply. I have talked to Vikas and he said that he will have an eye on it. I think its a standard feature compared to other finder solution that should be implemented. In the meantime can you tell me where in the code the sorting will be done?
Thanks
PSIJuly 1, 2014 at 1:46 pm #6974Plz try to put this code in your theme functions.php file
add_filter('pre_get_posts', 'geodir_apply_my_posts_orderby'); function geodir_apply_my_posts_orderby($query) { if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { if(!is_admin()) add_filter('posts_orderby', 'geodir_my_posts_orderby' ); } } function geodir_my_posts_orderby($orderby) { global $wpdb; if(!is_admin()) { $orderby = str_replace(", $wpdb->posts.post_date desc" , '', $orderby); } return $orderby ; }Let me know if this works.
Thanks for ur patience.
July 1, 2014 at 1:58 pm #6978worked for me! brilliant support! Thanks Vikas
April 11, 2015 at 4:43 pm #36910Just wanted to mention that the listing page does not sort alphabetically without the code provided here.. Even with the dropdown to change ascending/descending.
I’m using latest version + multiLocations.
April 11, 2015 at 6:33 pm #36924Hi Joel,
I just tested here: http://wpgeo.directory/attractions/?sort_by=post_title_asc
with latest everything and without that function and it works.
Could you please provide a URL and wp admin credentials for us to see?
Thanks
June 28, 2015 at 10:04 am #43883Hallo,
I would like to sort first always the featured customers randomly and after them there should be the free listings also randomly sorted.
Is it possible to modify Vikas’ code to achieve this effect?
add_filter('pre_get_posts', 'geodir_apply_my_posts_orderby'); function geodir_apply_my_posts_orderby($query) { if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { if(!is_admin()) add_filter('posts_orderby', 'geodir_my_posts_orderby' ); } } function geodir_my_posts_orderby($orderby) { global $wpdb; if(!is_admin()) { $orderby = str_replace(", $wpdb->posts.post_date desc" , '', $orderby); } return $orderby ; }June 29, 2015 at 3:33 pm #44010Hi,
no that is not possible.
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket