Hướng dẫn cài plugin wp post rating năm 2024

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.

How To Change Schema Type?


The default schema type is ‘Article’, if you want to change it to ‘Recipe’, you need to make use of the


5 filter as shown in the sample code above.

How To Add Your Site Logo For Google Rich Snippets


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


6 filter as shown in the sample code above.

How To Remove Ratings Image alt and title Text?


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


7 filter as shown in the sample code above.

How To use PNG images instead of GIF images?

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


8 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


9 filter as shown in the sample code above.

How Does WP-PostRatings Load CSS?

  • WP-PostRatings will load

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    0 from your theme’s CSS directory if it exists.
  • If it doesn’t exists, it will just load the default ‘postratings-css.css’ that comes with WP-PostRatings.
  • This will allow you to upgrade WP-PostRatings without worrying about overwriting your ratings styles that you have created.

How To Use Ratings Stats With Widgets?

  1. Go to

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    1
  2. The widget name is Ratings.

To Display Lowest Rated Post


    

  • Default: get_lowest_rated(‘both’, 0, 10)
  • The value ‘both’ will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Lowest Rated Post By Tag


    

  • Default: get_lowest_rated_tag(TAG_ID, ‘both’, 0, 10)
  • Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Lowest Rated Post In A Category


    

  • Default: get_lowest_rated_category(CATEGORY_ID, ‘both’, 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Highest Rated Post


    

  • Default: get_highest_rated(‘both’, 0, 10)
  • The value ‘both’ will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the highest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post By Tag


0

  • Default: get_highest_rated_tag(TAG_ID, ‘both’, 0, 10)
  • Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the highest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post In A Category


1

  • Default: get_highest_rated_category(CATEGORY_ID, ‘both’, 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the highest rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post Within A Given Period


2

  • Default: get_highest_rated_range(‘1 day’, ‘both’, 10)
  • The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post


3

  • Default: get_most_rated(‘both’, 0, 10)
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post In A Category


4

  • Default: get_most_rated_category(CATEGORY_ID, ‘both’, 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post Within A Given Period


5

  • Default: get_most_rated_range(‘1 day’, ‘both’, 10)
  • The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post


6

  • Default: get_highest_score(‘both’, 0, 10)
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post In A Category


7

  • Default: get_highest_score_category(CATEGORY_ID, ‘both’, 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post Within A Given Period


8

  • Default: get_highest_score_range(‘1 day’, ‘both’, 10)
  • The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.
  • The value ‘both’ will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace ‘both’ with ‘post’.
  • If you want to display the most rated pages only, replace ‘both’ with ‘page’.
  • The value 10 will display only the top 10 most rated posts/pages.

To Sort Highest/Lowest Rated Posts

  • You can use:

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    2
  • Or pass in the variables to the URL:

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    3
  • You can replace desc with asc if you want the lowest rated posts.

To Sort Most/Least Rated Posts

  • You can use:

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    4
  • Or pass in the variables to the URL:

    add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

    5
  • You can replace desc with asc if you want the least rated posts.

Один пользователь может оценить только 1 материал на сайте? Бред! Только зря потратил время на установку!