Brizy has an element called Rating which you can use to add a star rating on the page or template you are working on. You can either use the element to add a static or dynamic star rating with the help of ACF (Advanced Custom Fields). The ability to add a dynamic star rating is great if you want to create a website in which you need to add a unique rating to each page or post. Say you want to create a review blog and you want to add a unique rating for every review you write. For such a case, you can create a custom field (using ACF) dedicated to controlling (the number of stars) the Rating element of Brizy.
Follow the steps below to add a dynamic star rating in Brizy.
Step 1: Create a custom field group using ACF
First, you can create a custom field group using ACF and assign it to default post type (blog post). To do so, go to Custom Fields -> Add New on your WordPress dashboard (make sure you have installed and activated the ACF plugin). Give your custom field group a name and click the Add Field button to add a field.
For the first field (the field to control the Rating element), you can use the field type of number. You can set the minimum value and the maximum value on the Minimum Value and Maximum Value options.
To add more fields, you can can simply click the Add Field button. If you just want to add a field to control the Rating element then one field above is enough.
Once you are done adding the fields, click the Publish button to publish the custom field group. But first, make sure the custom field group is assigned to Post.
For more detailed instructions on how to create custom fields in ACF, you can refer to this page.
Once the custom field group is published, you should see a new set of fields beneath the WordPress editor every time you want to add a new blog post (assuming you assigned to custom field group to default post type). You can add your rating on the field you have specified.
Step 2: Create the custom template for blog post
Once you are done creating the custom fields, you can then create the custom template for the the default post type (blog post). To be able to do this, you need to use the pro version of Brizy as the feature to create custom templates is only available Brizy Pro.
Once you are ready, go to Brizy -> Templates. Click the Add New button to create a new template.
Give your template a name and set the condition on the Add New Condition section. Since you want to create a custom template for blog posts, you can include the template on all posts. Click the Add button to add a condition and then click the Publish button to publish the template.
Next, click the Edit with Brizy button to edit the template on the Brizy editor.
Note: Make sure to create the template from the same route as we showed above (add template name -> set display condition -> click the Publish button -> click the Edit with Brizy button). Otherwise, you might experience issues with the Post Title and Post Content elements.
On the Brizy editor, you can add any element for your custom template. For instance, you can add the Post Content element to add the post content, Post Title to add the post title, Post Info to add the post info, and so on.
Since your purpose of creating the custom template is to create a dynamic star rating, make sure to add the Rating element. You can place it anywhere.
Once the Rating element is added, click it to show to the settings bar and click the Rating tab.
On the settings bar, click the dynamic icon on the Rating option and select the custom field you have specified to control the star rating.
To style up the star icons, you can simply click the options available on the settings bar. For instance, you can click the Colors tab to change the icon color and click the Align tab to set the alignment.
You can read our previous article for more detailed instructions on how to create a custom single post template with Brizy. Once you are done editing the template, you can click the Update button on the bottom-right corner to apply the changes.
That’s it. You have successfully created a dynamic star rating in Brizy using ACF.