Title: Help customising :)
Last modified: November 11, 2017

---

# Help customising :)

 *  [rivmedia](https://wordpress.org/support/users/rivmedia/)
 * (@rivmedia)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/help-customising/)
 * Hi Lester
 * I’m trying to customise how the plugin displays, but I’ve ran into a bit a problem
   I don’t know how to fix 🙂
 * In the comments template instead of using :
 * `<?php if(function_exists('the_ratings')) { the_ratings(); } ?>`
 * I want to use this :
 *     ```
       <?php global $current_user, $post;
        $user_comment_count = get_comments(array('user_id' => $current_user->ID, 'post_id'=>$post->ID) ); ?>
   
       <?php if($user_comment_count) { 
       	echo '<h2>Thank you for your review,  please leave a star rating.</h2>';
          the_ratings();  
       } else {
       	echo' <h2>Leave a review first you may then give a star rating.</h2>'; 
           comment_form(array('class_submit'=>'button'));
       } 
       ?>
       ```
   
 * Which basically hides the rating, until a comment has been made. This works just
   fine and as expected, however when doing this, the JSON-LD doesnt output and 
   so when using the [https://search.google.com/structured-data/testing-tool/u/0/](https://search.google.com/structured-data/testing-tool/u/0/)
 * It doesnt show any schema, if i revert back to the original code it works fine.
 * Please could you advise where im going wrong.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/help-customising/#post-9674405)
 * Yes, it is by design, the plugin only outputs the markup when in a loop and not
   in the comment section/template.
 * There are just too many possibilities on where to place the code, I need to make
   the plugin as generic as possible and hence the decision.
 * You can manually output the markup if you wish. Feel free to refer to how I do
   here it [https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L1160-L1221](https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L1160-L1221)
 * This is the furthest I can help you with as I don’t provide support for plugin
   customization =)
 *  Thread Starter [rivmedia](https://wordpress.org/support/users/rivmedia/)
 * (@rivmedia)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/help-customising/#post-9674687)
 * Thanks for that reply Lester,
 * I did see it was designed for the main loop. But I can’t understand why your 
   code :
 * `<?php if(function_exists('the_ratings')) { the_ratings(); } ?>`
 * Works exactly how we want it to, in exactly the same location. But our code :
 *     ```
       <?php global $current_user, $post;
        $user_comment_count = get_comments(array('user_id' => $current_user->ID, 'post_id'=>$post->ID) ); ?>
   
       <?php if($user_comment_count) { 
       	echo '<h2>Thank you for your review,  please leave a star rating.</h2>';
          the_ratings();  
       } else {
       	echo' <h2>Leave a review first you may then give a star rating.</h2>'; 
           comment_form(array('class_submit'=>'button'));
       } 
       ?>
       ```
   
 * Doesn’t work, I actually think its something in our code which is missing rather
   than being a loop problem ? We’ve also tested our code in the main loop and have
   the same problem. I was hoping you could see something obvious as to why its 
   not working.
 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/help-customising/#post-9674688)
 * You can check the condition here [https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L1159](https://github.com/lesterchan/wp-postratings/blob/master/wp-postratings.php#L1159)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Help customising :)’ is closed to new replies.

 * ![](https://ps.w.org/wp-postratings/assets/icon.svg?rev=978014)
 * [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-postratings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-postratings/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-postratings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-postratings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-postratings/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/help-customising/#post-9674688)
 * Status: not resolved