Skip Navigation

[Resolved] Star Rating for Custom Post Types

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 8 replies, has 2 voices.

Last updated by AlimB3245 1 month, 2 weeks ago.

Assigned support staff: Waqar.

Author
Posts
#1724939

Tell us what you are trying to do?
I would like to use the star rating feature on my custom posts... is there any documentation? I couldn't find much documentation on star rating hence this question.. I would like the user to rate the custom posts on 3 criteria's .. would I have to put 3 star rating blocks in the content template? If I don't want this in the content template but in a modal that would pop up on a trigger, can I do this? Where would the ratings get stored? Would the ratings be anonymous or would they tagged to the logged in user?

Is there any documentation that you are following?
Couldn't find much.

Is there a similar example that we can see?

What is the link to your site? hidden link

#1725671

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thanks for asking! I'd be happy to help.

The Toolset's "Star Rating" block is very basic and can only be used to show a numeric value (fixed or linked to a custom field), in the form of rating stars.

It can't be used to input a rating value from the users and store them independently for each user and post/page.

For a full feature star rating system, you can use a third-party plugin and following articles review some of the popular options:
hidden link
hidden link

regards,
Waqar

#1726427

Hi Waqar

Thanks for the update..:-)..

Even for the basic use, is there any documentation? I know I could try it out and know but I really don't know what to expect and normally a video or a tutorial page gives you an idea..

no worries, if there's none.. but please do let me know if there is.

Regards,
Alim

#1728161

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alim,

Thanks for writing back.

You'll find a good usage example of this "Star Rating" block, on the homepage of our "Gyms and Trainers" demo website.
( ref: https://discover-wp.com/site-types/gyms-and-trainers/ )

Here is a link to the relevant section from its course, which also includes a video tutorial:
https://toolset.com/lesson-placement/lesson-placements-1621277-1622337/

I hope this helps.

regards,
Waqar

#1728229

Hi Waqar

Thanks for this update..:-)..

I created a demo gym site and from this I understood that the Rating is just a number field and the Rating block just displays this number in a STAR RATING format.. am I right?

So this is not really a dynamic value that's calculated based on multiple ratings provided to the gym.. it's just a static value updated on the gym post.. right?

As you are checking the opticians view for the other ticket, let me give you an example of what I need.. anyone who comes to the opticians view would have a rating option .. in fact 3 rating options.. and a review.. and on submitting this rating, this data is stored.. mulitple such ratings/reviews are added to each opticians and and an average of this rating is displayed on the opticians frontend..

Can I achieve this with Toolset? I am assuming I'd have to create a REVIEW Post with the 3 rating sections and a review comment box.. could you tell me if I am thinking right? or it's not something Toolset is programmed to do? Please advise..

Regards,
Alim

#1729539

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alim,

> I created a demo gym site and from this I understood that the Rating is just a number field and the Rating block just displays this number in a STAR RATING format.. am I right?
> So this is not really a dynamic value that's calculated based on multiple ratings provided to the gym.. it's just a static value updated on the gym post.. right?

- Yes, your understanding is correct for both these points and this is exactly what I meant in my first reply to this ticket.

> Can I achieve this with Toolset? I am assuming I'd have to create a REVIEW Post with the 3 rating sections and a review comment box.. could you tell me if I am thinking right? or it's not something Toolset is programmed to do?

- I'm afraid, there is no built-in feature available in Toolset for this so it will require a fair deal of PHP and JS code customizations.

You can add a new custom post type "Reviews" with three numeric custom fields, one for each rating section and link it with the "Opticians" post types through post relationships. A Toolset form can be used to create a new review post connected with an optician post, but some challenges that you'll face would be:

a). Limiting the use of this review form, so that a single user can only create exactly one review post for each optician post.

b). You'll need a custom function that can get all reviews posts related to a particular optician post and then calculate the average rating which can be displayed on the front-end.

If you decide to go with this approach and need someone to help you with these customizations, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

Alternately, you can also check out any third-party pre-built rating and review plugin, to see if it can be made to work for your requirements.

regards,
Waqar

#1733839

Hi Waqar

I do have a custom created plugin for ratings that I was using some time back but I wasn't sure if I could use it with Toolset.. but I am trying to do that now..

I have enabled it on the opticians page.. and this plugin would have its own tables and I am sure there's some way to query the results for a particular post and have that data..

Now if I am able to do that, would I only need to create a PHP script to put that data into a custom field that I create in Toolset?

Could it be this simple?

I had this idea after you created a script for me for the get-post-count for another ticket and it was so cool.. I am not a developer and so for me this was magic!..;-).. so if I have the ratings data somewhere can I pick this data up from there and put it into a Toolset-created custom field?

Please do advise.

Regards,
Alim

#1734381

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alim,

Yes, you're thinking on the right lines.

This is possible using custom code and will require an understanding of PHP and WordPress customization. If you're not comfortable doing this on your own, we have a list of recommended contractors at:
https://toolset.com/contractors/

Here are the basic steps, which will help you discuss this project with your developer:

Step 1: Getting the rating data from the plugin's tables in the database:

hidden link
https://codex.wordpress.org/Class_Reference/wpdb

Step 2: Calculate the average rating of a particular optician and save it as a custom field value in a Toolset field:

https://developer.wordpress.org/reference/functions/update_user_meta/
https://developer.wordpress.org/reference/functions/update_post_meta/

Once the average rating value is correctly saved in a numeric Toolset Types field, you can use the "Star Rating" block to display it on the front-end.

regards,
Waqar

#1735341

My issue is resolved now. Thank you!

Thanks for the guidance and support.. really appreciate it..:-)..

Have a nice day..:-)..

Regards,
Alim