Contributors: jconroy
Tags: acf, ratings, custom field
Requires at least: 3.5
Tested up to: 3.5
Stable tag: 1.0
Adds a 'star-rating' field type for the Advanced Custom Fields WordPress plugin.
Adds a 'star-rating' field type for the Advanced Custom Fields WordPress plugin.
This add-on will work with:
- version 4 and up of ACF
This add-on can be treated as both a WP plugin and a theme include.
Install as Plugin
- Copy the 'acf-field-star-rating' folder into your plugins folder
- Activate the plugin via the Plugins admin page
Include within theme
- Copy the 'acf-field-star-rating' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
- Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-star_rating.php file)
add_action('acf/register_fields', 'my_register_fields');
function my_register_fields()
{
include_once('acf-field-star-rating/acf-star_rating.php');
}
This plugin actually adds a standard star rating field and an average star rating field that automatically generates the average score based on other standard star rating fields in the field group. This is useful for storing over all ratings if there a few rating criteria are being used.
Standard Star Rating Field
- Add a new field with a Field Type of "Star Rating".
- Set the "Number of Stars" that will be displayed to choose e.g. 5 from along with the default rating e.g. Screenshot 1 below.
- Publish the field / group as per ACF standard use. When viewing the group on the post edit screen the "Star Rating" field will now be available e.g. Screenshot 2 below.
Average Star Rating Field
- Add a number of the standard "Star Rating" fields as per above.
- Add a new "Star Rating Average" field.
- Set the "Number of Stars" that will be displayed to match the number set for the standard star ratings fields.
- Publish the field / group as per ACF standard use. When viewing the group on the post edit screen the "Star Rating Average" field will now auto populate the average star score based on the other standard star rating fields in the same group. e.g. Screenshot 3 below.
Retrieve Ratings
- Retrieve the ratings by using standard ACF functions for obtaining field values.
- Initial release