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?
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.
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?
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
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.
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
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?
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