Skip Navigation

[Resolved] Need to sort by Location and Featured Trial then use CSS to highlight top resuls

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Shane 4 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1545557
1 - Featured Trials.png
2 - Relevanssi Sort.png

I have 2 issues:

1). SEARCH BY LOCATION:
I have a view that searches by location then sorts by proximity to visitor. I then need to sort the results by another field called "Featured Trials". I then need to highlight these Featured Trials with some CSS styling ie. box around top results, different color etc.

I could not find documentation around this.

I want this to look like the a Google SERP where the top paid advertisers are highlighted.

Here is my page:
hidden link

2). TEXT INPUT SEARCH RESULTS SORT BY LOCATION OF VISITOR:
I have a view that allows a visitor to input text to search by health condition. I want the results to sort based on location of visitor. I get a warning that Relevanssi will sort by relevance and does not allow sorting by visitor location. Is there a way around this?

Here is my page:
hidden link

#1545811

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-03-10 at 10.35.14 AM.png

Hi Cecilia,

Thank you for getting in touch. Normally we answer 1 issue per thread. However since the problems are related then I will handle them here.

1). SEARCH BY LOCATION:
I have a view that searches by location then sorts by proximity to visitor. I then need to sort the results by another field called "Featured Trials". I then need to highlight these Featured Trials with some CSS styling ie. box around top results, different color etc.

I could not find documentation around this.

I want this to look like the a Google SERP where the top paid advertisers are highlighted.

A. Given that you are using relevanssi as well, you wouldn't be able to get the results already sorting. You can however make use of the frontend sorting feature using the sorting controls button. See Screenshot

This way users will have the option to sort the view.

Regarding here " I then need to highlight these Featured Trials with some CSS styling ie. box around top results, different color etc."

You can make use of our conditional code in order to the items differently. So if a post is a Featured trial then you will add it with a different class vs one without. Example


[wpv-conditional if="( '[types field='my-featured-field'][/types]' eq 'featured')"]
<div class='featured'>

some content with special styling

</div>
[/wpv-conditional]

[wpv-conditional if="( '[types field='my-featured-field'][/types]' new 'featured')"]
<div >

some content without special styling
</div>
[/wpv-conditional]

2). TEXT INPUT SEARCH RESULTS SORT BY LOCATION OF VISITOR:
I have a view that allows a visitor to input text to search by health condition. I want the results to sort based on location of visitor. I get a warning that Relevanssi will sort by relevance and does not allow sorting by visitor location. Is there a way around this?

A. Similar to my answer above you won't be able to use the regular sorting to do this.

Please let me know if this helps.

Thanks,
Shane

#1549831

thank you for your response to #1.

#2 ) Can I create a secondary sort by zipcode or Visitor Location with custom code?

#1550173

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cecilia,

#2 ) Can I create a secondary sort by zipcode or Visitor Location with custom code?

You wouldn't need to use custom code because as long as these fields are types fields then you should be able to use the frontend sorting control as well to add frontend sorting for these fields.

Thanks,
Shane

#1556277
Health Condition Sort 2.png
Health Condition Sort 1.png

I decided to reconfigure my search feature. Please take a look at this page:

hidden link

I have a dropdown with the health conditions that is supposed to sort the results by distance from Visitor location. I am in Florida and when I choose "Endocrinology", the Wisconsin result shows up first (it should be last). The rest of the sort is fine. Same thing when I try to search by "Gastroenterology". It is not in the correct order at all.

Here is how i have it set up in Toolset View (see screenshots).

Here is admin access to my site if you want to go in there:

Thank you.

#1557489

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cecilia,

Unfortunately on my end the distance works fine. Could you try the page again?
hidden link

I've added this shortcode below in order to gain the distance from my location to the posts being displayed and they all sort correctly.

Distance: [wpv-geolocation]
[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-clinical-trial-site-address']
[/wpv-geolocation]

Check on your end to see if you are getting the distance values in a decreasing number.

Thanks,
Shane

#1557763

i had a couple people test it yesterday and it didn't work. but it is working for me now. thank you!

#1557789

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cecilia,

Great, I'm happy I was able to get this up and running for you.

If there are no further queries on this issue then you can go ahead and mark this ticket as resolved.

Thanks,
Shane