Skip to content

Instantly share code, notes, and snippets.

@codeboxr
Last active August 29, 2015 14:00
Show Gist options
  • Save codeboxr/11138240 to your computer and use it in GitHub Desktop.
Save codeboxr/11138240 to your computer and use it in GitHub Desktop.
showing avg rating using direct function call
/**
* Show avg rating for multiple posts for same form id,
* calls from shortcode or direct function call or from widget
*
* @param $option
* @param int $show_title
* @param int $show_form_id
* @param int $show_text
* @param int $show_star
* @param int $show_single
* @param int $text_label
*
* @return string
*/
//function standaloneSinglePostRatingSummary($option, $show_title = 0, $show_form_id = 0, $show_text = 0, $show_star = 1, $show_single = 0 , $text_label = '')
//write this code in wordoress loop, if you don't understand what is loop in wordpress then please see it here https://codex.wordpress.org/The_Loop
if(function_exists('standaloneSinglePostRatingSummary')):
global $post; //if you are using this outside of wordpress loop then comment this
$form_id = 1; //asign form id as you need.
$post_id = $post->ID; //if you are using this outside of wordpress loop then set the post id as it need , example $post_id = your post id here ;
$option = array(
'form_id' => array($form_id),
'post_id' => array($post_id)
);
echo standaloneSinglePostRatingSummary($option);
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment