Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as off-topic by Pieter Goosen, birgire, cybmeta, Mark Kaplun, G. M. Nov 27 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.

3 Answers 3

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

share|improve this answer
    
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
up vote 0 down vote accepted

Here it is:

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

then insert in the theme:

wp_gdsr_comment_integrate_standard_result(get_comment_ID());
share|improve this answer

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.']'); ?>
</div>
share|improve this answer

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