i needed a voting system for a client’s wordpress website so i installed this plugin: kk Star Ratings
the standard version is great but has very few options. the quickest way to achieve what the client wanted was to customize the plugin a little bit
show voting only for logged in users
i had to replace the voting box with a message inviting the user to login/signup
i edited the file /wp-content/plugins/kk-star-ratings/index.php
search for this line:
1 |
return $markup; |
and replace it with:
1 2 3 4 5 6 7 8 |
if(function_exists('kk_star_ratings')) { if ( is_user_logged_in() ) { return $markup; } else { echo 'Please login or signup to vote'; } } |
of course you can include HTML code between ‘ ‘ to further edit the message: include a link to login page, change the appearance (float, background)
hide voting on some posts
with kk Star Ratings you can choose where you want the ratings to be placed (homepage, archives, posts, pages, categories) but you can’t hide it from some posts (custom posts in my case)
so i edited the file /wp-content/plugins/kk-star-ratings/index.php
search for this line:
1 |
return $markup; |
and replace it with:
1 2 3 4 5 6 7 |
if(function_exists('kk_star_ratings')) { if(!in_array(get_the_ID(), array(101,151,1001))) { return $markup; } } |
where 101,151,1001 from the array are the ID’s of the posts
Hi,
I have several comparison tables on my site, used to compare products.
I want to use the rating shortcode to allow users to submit votes on each product.
The problem is that if you vote on one product, it applies the same vote to all other products.
Is there a way to allow for multiple, unique votes on one singular page?
e.g. https://inplayempire.com/best-uk-bookmakers/top-uk-betting-sites/
Best
Charlie
@kamalkhan
Owner
kamalkhan commented on 16 Feb 2018
By default, the star ratings is applied for the current post/page or custom post being viewed.
In your case, you want to distinguish star ratings in the same post/page without sticking it to the current post id. To do that, you have to manually use the shortcode and set the id of the custom post.
Example shortcode use case:
Product Foo [kkstarratings id=”590″]
Product Bar [kkstarratings id=”591″]
Product Baz [kkstarratings id=”592″]
If you use id’s where do you explain the id? In css?
And how ?
Hi thanks for your awesome post.
i have a problem.
when i install kk star ratings on my site i tested my site on google structured data testing tool and i find this errors.
“Field ratingValue may not be empty”
“One of ratingCount or reviewCount must be provided”
please help me.
how can i add one star to all wordpress posts for resolve this problem.
Thank you, it works!
Thank you for article .
in need show just ” ratingValue ” in category post.
please help me. Thanks .