wp_star_rating

SummerySummery

Output a HTML element with a star rating for a given rating.

Syntax

wp_star_rating( array $args = array() )

DescriptionDescription

Outputs a HTML element with the star rating exposed on a 0..5 scale in half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the number of ratings may also be displayed by passing the $number parameter.

ParametersParameters

$args

(array) (Optional) Array of star ratings arguments.

  • 'rating'
    (int|float) The rating to display, expressed in either a 0.5 rating increment, or percentage. Default 0.
  • 'type'
    (string) Format that the $rating is in. Valid values are 'rating' (default), or, 'percent'. Default 'rating'.
  • 'number'
    (int) The number of ratings that makes up this rating. Default 0.
  • 'echo'
    (bool) Whether to echo the generated markup. False to return the markup instead of echoing it. Default true.

Default value: array()

ReturnReturn

(string) Star rating HTML.

SourceSource

File: wp-admin/includes/template.php


			

ChangelogChangelog

Changelog
Version Description
4.4.0 Introduced the echo parameter.
3.8.0 Introduced.
Scroll to Top