Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n7studios/4c3520a88b040c7ef758c8539e31cd0c to your computer and use it in GitHub Desktop.
Save n7studios/4c3520a88b040c7ef758c8539e31cd0c to your computer and use it in GitHub Desktop.
<?php
/**
* For developers who want to directly access the numerical rating data for a Post, the below
* functions can be used.
*/
/**
* Get the Post's Total Number of Ratings
*
* @param int $post_id Post ID
* @return int Total Number of Ratings
*/
if ( function_exists( 'get_post_total_ratings' ) ) {
$result = get_post_total_ratings( $post_id );
}
/**
* Get the Post's Average Rating
*
* @param int $post_id Post ID
* @return decimal Average Rating
*/
if ( function_exists( 'get_post_average_rating' ) ) {
$result = get_post_average_rating( $post_id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment