I need to insert a rating straight away after having programmatically created a post in WordPress and added a comment.

What is the (GDSR) function to call to fire the rating once I've got the post id/comment id?

closed as off-topic by Pieter Goosen, birgire, cybmeta, Mark Kaplun, gmazzap Nov 27 '14 at 14:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


If you are talking about using GD star rating in a theme file like
single.php or page.php you can use a shortcode like so:

<div class="rateit"><?php echo do_shortcode('[starrater tpl=10]'); ?></div>

You can choose which shortcode to use in the panel
of "create new post"... youll find it in the toolbar.


if you are talking about using a file that is completely out of wordpress you should first "load wordpress framework" like this above everything in the page:

require( '../wordpress_install_root/wp-load.php' );

And then you the shortcode above...


Hope this helps. Sagive

  • Thanks Sagive, but I think this is not the right solution for my problem. I believe the following code is not the best solution but I've got it working using: gdsrBlgDB::save_vote($post_id, $user_ID, $ip, $ua, $vote); Now I need to see the rating for the post for each voter near their comment. – Francois Mar 21 '12 at 11:44

Here it is:

gdsrBlgDB::save_vote($post_id, $user_ID, $ip, $ua, $vote, $comment_id);

then insert in the theme:


I was trying to print a list of recent comments, along with the rating, and this is the only way I could figure out how to do so outside of the loop.

Since I'm using a custom query to get the comments, here is how I was able to show the ratings with a list of recent comments:

<div class="rateit">
<?php echo do_shortcode('[starrater post='.$comment->comment_post_ID.']'); ?>

Not the answer you're looking for? Browse other questions tagged or ask your own question.