Hello Toolset team,
https://wordpress.org/plugins/yet-another-stars-rating/
I am using this plugin for a star rating. and the requirement to allow sorting by star rating as well.
I have to add sorting options for Alphabetically(Done), Latest post(Done), and Star Rating (I need help to get in hook[action/filter]).
I have checked your document guideline but have not found to exact hook for this.
this doesn't work directly toolset plugin so can you please share any hook or code tip to apply by filter or anything...
Here I have attached a screenshot of the shooting option and you can visit the developer's website for info hidden link
Thank you in advance
Hello,
Do you have any document from "Yet Another Stars Rating" plugin about this:
- How do you store the rating value for each post in database?
If it is a custom post field, you can follow our document to setup the sorting control in post view:
https://toolset.com/course-lesson/creating-a-custom-search/#add-front-end-sorting-to-search-results
section "Add front-end sorting to search results"
If it is other custom database table, you will need to consider custom codes, for example:
Use wpv_filter_query filter to trigger a custom PHP function:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
In this PHP function, setupthe Order & Orderby Parameters of Views query:
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
Hi Luo Yang,
Thank you for your reply.
Do you have any document from "Yet Another Stars Rating" plugin about this:
- How do you store the rating value for each post in the database?
==> This is stored in a custom database table. let me know more detail.
My 2nd question is how I will add this custom short-order option add into the shortlist option. (Showing on the top of the list.)
See the attached screenshot. for this.
When selecting this option then apply this sort order to the post list.
Once again thank you.
Q1) ==> This is stored in a custom database table. let me know more detail.
Toolset plugins are WordPress plugins, can only works with WordPress database tables.
Since "Yet Another Stars Rating" plugin stores rating value in other custom database tables, so you can not use it to sort the view's result by default, there isn't such kind of built-in feature to sort the result by other custom database tables.
You will need to consider custom codes, for example sync the rating value with a custom post field, then use that post field as orderby parameter.
Q2) For the new question:
how I will add this custom short-order option add into the shortlist option.
Please check answer of Q1), you can add new option into the sorting control block, see my screenshot
Hi Luo,
Thank you for your reply. we will check and get back to you.
Thank You
OK, I have marked this thread as "Waiting for feedback" status, please update here if you still need assistance for it. thanks
Hi Luo,
I need some time for checking this custom filter option. So please wait for some time for on this.
Thank you
OK, please update here if you still need assistance for it. thanks