Skip to content
Advertisement

Convert number to star rating php shortcode?

I’ve used the following code in order to generate a star rating inside a shortcode on my site.

JavaScript

I’m new to PHP and incredibly confused. The issue I have is, how can I make $starNumber a variable number that I can change inside the shortcode? For example, if I wanted to show 3.5 stars with a shortcode such as [starrating rating="3.5"]

Everything I try only seems to break the shortcode. Any help would be greatly appreciated.

Thanks!

Advertisement

Answer

You need to send the star number as a parameter to the function as follows:

JavaScript

When using the shortcode in the CMS use it like this [starrating starNumber=”5″]

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement