Skip Navigation

[Résolu] Block Star Ratings not Showing Custom Fields

This support ticket is created Il y a 2 années et 11 mois. 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.

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.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 réponses, has 2 voix.

Last updated by Luo Yang Il y a 2 années et 11 mois.

Assisted by: Luo Yang.

Auteur
Publications
#2060509
Screen Shot 2021-05-17 at 4.26.52 PM.png

I have three relevant post types:
Property Managers. In a one to many relationship with -
|__ Rentals. In a one to many relationship with -
|__ Rental Ratings.

I'm displaying a rental and want to show all related ratings. I suppose I could have used a repeatable field for rental ratings, but with the stars, comments, etc., it felt easier to do another post type. So I want to show those (in a compact form) on the same page. Everything works well except (so far) the ratings. When I attempt to use a dynamic source, I see the screenshot:

The custom fields are nowhere to be found. Is this because they exist within a view within a content template? The template displays the Rentals and the view is for Rental Ratings and has this filter:
Select posts in a Rentals Property Ratings relationship that are related to the Post where this View is shown.

Am I missing something?

#2060763
rating.JPG

Hello,

How do you setup the "Ratings" field?
I have tried it in a fresh WP installation + the latest version of Toolset plugins, setup the "Ratings" field as a custom number field, it works fine, I can setup the "Dynamic Value Source" options without any problem. see my screenshot rating.JPG

If the "Ratings" field is a repeating field, then the "Star Rating" block will use the first instance as the result.

#2062001

I have it set as a Radio field. I'll be using a form so that people rate these on the front end, so that's useful. But if I can achieve the same thing with a number field, I'll do that instead.

It's not a repeatable field because it's part of a different post type (as outlined above). The fact that the field group doesn't even show up as an option indicates that the problem likely isn't whether or not the field is numbers or radio.
I made a traditional View (couldn't see how to properly do it as a Block View) that displays this Rating sub-type. I then inserted it into the Content Template. But when I go to the content template, I see what is in the screenshot above. Is there a different way to do this properly?

#2062345

Yes, you are right, you need to replace the radio field with a custom number field, and in your post forms, you can display the "Ratings" as a radio field with generic field shortcode, for example:

[cred_generic_field type='radio' field='wpcf-ratings']
{
"required":0,
"default":[],
"options":[{"value":"1","label":"1"},{"value":"2","label":"2"},{"value":"3","label":"3"},{"value":"4","label":"4"},{"value":"5","label":"5"}], 
"persist":1
}
[/cred_generic_field]

Please replace "ratings" with your custom number field slug

More help:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_generic_field

#2063071

I will make the field change, but can you confirm whether or not my method with the View and Content Template is correct for making a star rating relationship on the front end? That's kind of the key to this whole thing.

#2063693

Yes, I have tried it in my localhost, it works fine, see above screenshot:
https://toolset.com/wp-content/uploads/2021/05/2060763-rating.jpg

#2064683

It still doesn't work.

I want to be clear that the ratings are a separate post type from the rentals. Therefore when I insert a "star rating" block, it is for the "rental ratings" post type NOT the "rentals" post type. And defining that through the block editor is my biggest question here.

I'm used to doing this the old fashioned way, but would like to use blocks so the rest of my team can also edit these things easily. What is the step by step guide to getting this to work?

#2066165

I assume there is one-to-many relationship between post types "Rentals" and "Rental Ratings".

If it is, in the single "Rentals" post, you can setup a view block:
- Query "Rental Ratings" posts
- Filter by the one-to-many relationship between post types "Rentals" and "Rental Ratings"
- In view's loop, display the "star rating" block

I have enabled the private message box, if you need more assistance for it, please problem a test site with the same problem, also point out the problem page URLs

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.