Installing WP Review Site is easy and should take just a few minutes:
Edit your theme to include the WP Review Site ratings input and display boxes.
WordPress themes include several files that display posts, where you may want to display the average ratings for those posts. These include index.php (blog’s index), single.php (single post), archive.php (post archives), search.php (search results). To display average ratings for a post, call either ratings_table() or ratings_list() within The Loop. See the function reference below for example code.
To collect ratings from users, you need to add the ratings input snippet to your comment form, which is in your theme’s comments.php. Locate where the user inputs and comment textarea appear in your theme, and add a call to ratings_input_table() or ratings_input_list(), ensuring the code appears between the <form> and </form> tags. See the function reference below for example code.
To display the ratings left with individual comments (aka reviews), you will need to add a snippet to your comment theme, comments.php. Locate the loop in which comments are displayed. This usually begins with foreach ($comments as $comment):. Within this loop, near where the comment text is displayed, add a call to either comment_ratings_table() or comment_ratings_list(). See the function reference below for example code.
Outputs a table with average ratings for the current post. This function can be called within The Loop with no arguments, or outside The Loop by specifying the ID of the post to display ratings for.
Usage Example:
<?php if (function_exists('ratings_table')) ratings_table(); ?>
Output Example:
<table class="ratings">
<tr><td class="rating_label">Price</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
<tr><td class="rating_label">Support</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
<tr><td class="rating_label">Reliability</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
</table>
Outputs an unordered list with average ratings for the current post. This function can be called within The Loop with no arguments, or outside The Loop by specifying the ID of the post to display ratings for.
Usage Example:
<?php if (function_exists('ratings_list')) ratings_list(); ?>
Output Example:
<ul class="ratings">
<li><label class="rating_label">Price</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
<li><label class="rating_label">Support</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
<li><label class="rating_label">Reliability</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
</ul>
Returns an array with average ratings for the current post. This function can be called within The Loop with no arguments, or outside The Loop by specifying the ID of the post to display ratings for. Since the array contains numeric values for each dimension posts or pages are rated on, you may use num_to_stars() to convert this number to star graphics.
Usage Example:
<?php if (function_exists('get_ratings')) $ratings = get_ratings(); ?>
Output Example:
This function has no output. The array returned has the following format:
array(
[Price] => 3.5,
[Support] => 2.5,
[Reliability] => 3.2
)
Displays the number of unique reviews of the current post with an average rating of 3 stars or higher.
Usage Example:
<?php if (function_exists('positive_reviews')) echo positive_reviews(); ?> Positive Reviews
Output Example:
8 Positive Reviews
Displays the number of unique reviews of the current post with an average rating of less than 3 stars.
Usage Example:
<?php if (function_exists('negative_reviews')) echo negative_reviews(); ?> Negative Reviews
Output Example:
2 Negative Reviews
Returns an array with the number of positive (3 star or higher) and negative reviews received by the current post.
Usage Example:
<?php if (function_exists('get_positive_negative_count')) $counts = get_positive_negative_count(); ?>
Output Example:
This function has no output. The array returned has the following format:
array(
[positive] => 8,
[negative] => 2
)
Outputs a table with ratings submitted with the specified comment. This function can be called within the comments loop in comments.php with no arguments, or outside the loop by specifying the ID of the comment to display ratings for. If used within a comment display loop, it expects the current comment to be called $comment.
Usage Example:
<?php if (function_exists('comment_ratings_table')) comment_ratings_table(); ?>
Output Example:
<table class="ratings">
<tr><td class="rating_label">Price</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
<tr><td class="rating_label">Support</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
<tr><td class="rating_label">Reliability</td><td class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</td></tr>
</table>
Outputs an unordered list with ratings submitted with the specified comment. This function can be called within the comments loop in comments.php with no arguments, or outside the loop by specifying the ID of the comment to display ratings for. If used within a comment display loop, it expects the current comment to be called $comment.
Usage Example:
<?php if (function_exists('comment_ratings_list')) comment_ratings_list(); ?>
Output Example:
<ul class="ratings">
<li><label class="rating_label">Price</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
<li><label class="rating_label">Support</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
<li><label class="rating_label">Reliability</label> <span class="rating_value"><img src="/wp-content/plugins/review-site/star.gif" />...</span></li>
</ul>
Outputs a table which collects ratings within the comment form of a post or page. Includes HTML which displays a table containing the dimensions you want to collect ratings for (ex: “value”, “support”, “reliability”) as well as JavaScript star rating widgets that allow ratings to be set by clicking on star images. Must be used between the <form> and </form> tags in comments.php for ratings to be submitted along with the comment.
Usage Example:
<?php if (function_exists('ratings_input_table')) ratings_input_table(); ?>
Output Example:
<table class="ratings"> <tr> <td class="rating_label">Features</td> <td class="rating_value"> <a onclick="rateIt(this, 0)" id="0_1" title="1" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_2" title="2" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_3" title="3" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_4" title="4" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_5" title="5" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <input type="hidden" id="0_rating" name="0_rating" value="0" /> </td> </tr> <tr> <td class="rating_label">Support</td> <td class="rating_value"> <a onclick="rateIt(this, 1)" id="1_1" title="1" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_2" title="2" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_3" title="3" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_4" title="4" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_5" title="5" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <input type="hidden" id="1_rating" name="1_rating" value="0" /> </td> </tr> </table>
Outputs an unordered list which collects ratings within the comment form of a post or page. Includes HTML which displays a list containing the dimensions you want to collect ratings for (ex: “value”, “support”, “reliability”) as well as JavaScript star rating widgets that allow ratings to be set by clicking on star images. Must be used between the <form> and </form> tags in comments.php for ratings to be submitted along with the comment.
Usage Example:
<?php if (function_exists('ratings_input_list')) ratings_input_list(); ?>
Output Example:
<ul class="ratings"> <li> <label class="rating_label" style="float: left">Features</label> <div class="rating_value"> <a onclick="rateIt(this, 0)" id="0_1" title="1" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_2" title="2" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_3" title="3" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_4" title="4" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <a onclick="rateIt(this, 0)" id="0_5" title="5" onmouseover="rating(this, 0)" onmouseout="rolloff(this, 0)"></a> <input type="hidden" id="0_rating" name="0_rating" value="0" /> </div> </li> <li> <label class="rating_label" style="float: left">Support</label> <div class="rating_value"> <a onclick="rateIt(this, 1)" id="1_1" title="1" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_2" title="2" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_3" title="3" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_4" title="4" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <a onclick="rateIt(this, 1)" id="1_5" title="5" onmouseover="rating(this, 1)" onmouseout="rolloff(this, 1)"></a> <input type="hidden" id="1_rating" name="1_rating" value="0" /> </div> </li> </ul>
Returns an HTML fragment containing star images depicting a numeric rating between 0 and 5. Values are rounded down to the nearest half star.
Usage Example:
<?php echo num_to_stars(3.8); ?>
Output Example:
<img src="/wp-content/plugins/review-site/star.gif" alt="3.8" /> <img src="/wp-content/plugins/review-site/star.gif" alt="3.8" /> <img src="/wp-content/plugins/review-site/star.gif" alt="3.8" /> <img src="/wp-content/plugins/review-site/star-half.gif" alt="3.8" /> <img src="/wp-content/plugins/review-site/star-empty.gif" alt="3.8" />
Displays a link to the URL saved on the post or page edit screen for the current post or page. Specify the link text with the first parameter, or “Visit This Site” will be printed by default.
Usage Example:
<?php visit_site_link('Visit This Web Host'); ?>
Output Example:
<a href="http://www.example.com/affiliate/?affid=12345">Visit This Web Host</a>