Adds an AJAX rating system for your WordPress site's content.
wp-content/themes/<YOUR THEME NAME>/index.php
<?php while (have_posts()) : the_post(); ?>
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
[ratings]
into the selected post/page content and it will embed ratings into that post/page only.[ratings id="1"]
, where 1 is the ID of the post/page ratings that you want to display.[ratings id="1" results="true"]
, where 1 is the ID of the post/page ratings results that you want to display.https://github.com/lesterchan/wp-postratings
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
<?php add_filter( 'wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype' ); function wp_postratings_schema_itemtype( $itemtype ) { return 'itemscope itemtype="http://schema.org/Recipe"'; } ?>
The default schema type is ‘Article’, if you want to change it to ‘Recipe’, you need to make use of the wp_postratings_schema_itemtype
filter as shown in the sample code above.
<?php add_filter( 'wp_postratings_site_logo', 'wp_postratings_site_logo' ); function wp_postratings_site_logo( $url ) { return 'http://placehold.it/350/150.png'; } ?>
By default, the plugin will use your site header image URL as your site logo. If you want to change it, you need to make use of the wp_postratings_site_logo
filter as shown in the sample code above.
<?php add_filter( 'wp_postratings_ratings_image_alt', 'wp_postratings_ratings_image_alt' ); function wp_postratings_ratings_image_alt( $alt_title_text ) { return ''; } ?>
add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );
By default, the comment author ratings are not displayed. If you want to display the ratings, you need to make use of the wp_postratings_display_comment_author_ratings
filter as shown in the sample code above.
function custom_rating_image_extension() { return 'png'; } add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
The default image extension if ‘gif’, if you want to change it to ‘png’, you need to make use of the wp_postratings_image_extension
filter as shown in the sample code above.
function custom_rating_cookie_expiration() { return strtotime( 'tomorrow' ) ; } add_filter( 'wp_postratings_cookie_expiration', 'custom_rating_cookie_expiration', 10, 0 );
The default cookie expiration if ‘time() + 30000000’, if you want to change the lenght of the experation, you need to make use of the wp_postratings_cookie_expiration
filter as shown in the sample code above.
postratings-css.css
from your theme’s CSS directory if it exists.WP-Admin -> Appearance -> Widgets
<?php if (function_exists('get_lowest_rated')): ?> <ul> <?php get_lowest_rated(); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_lowest_rated_tag')): ?> <ul> <?php get_lowest_rated_tag(TAG_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_lowest_rated_category')): ?> <ul> <?php get_lowest_rated_category(CATEGORY_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_rated')): ?> <ul> <?php get_highest_rated(); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_rated_tag')): ?> <ul> <?php get_highest_rated_tag(TAG_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_rated_category')): ?> <ul> <?php get_highest_rated_category(CATEGORY_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_rated_range')): ?> <ul> <?php get_highest_rated_range('1 day'); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_most_rated')): ?> <ul> <?php get_most_rated(); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_most_rated_category')): ?> <ul> <?php get_most_rated_category(CATEGORY_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_most_rated_range')): ?> <ul> <?php get_most_rated_range('1 day'); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_score')): ?> <ul> <?php get_highest_score(); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_score_category')): ?> <ul> <?php get_highest_score_category(CATEGORY_ID); ?> </ul> <?php endif; ?>
<?php if (function_exists('get_highest_score_range')): ?> <ul> <?php get_highest_score_range('1 day'); ?> </ul> <?php endif; ?>
<?php query_posts( array( 'meta_key' => 'ratings_average', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
http://yoursite.com/?r_sortby=highest_rated&r_orderby=desc
<?php query_posts( array( 'meta_key' => 'ratings_users', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
http://yoursite.com/?r_sortby=most_rated&r_orderby=desc
post_id
to second argument of wp_postratings_expand_ratings_template
.get_post()
wp_postratings_disable_richsnippet
to disable richsnippet on the fly.WP-Admin -> Ratings -> Rating Options
to disable the ratings component of the Rich Snippet. Props @8ctopusexpand_ratings_template
to wp_postratings_expand_ratings_template
for consistency.wp_postratings_ipaddress
and wp_postratings_hostname
to allow user to overwrite it.