Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

        $author_id, $args = array())


Calculate aggregated rating for all posts belonging to a specified author. Array $args contains additional settings. This function return object with the calculated aggregated rating containing rating and votes (and also minimal and maximal rating and posts for individual items in the calculation.


  • $author_id: valid user ID
  • $args: array with additional settings

$args array

  • post_type: name of the post type, default: ‘post’
  • method: name of the rating method
  • series: name of the series for rating methods that have series
  • id__in: list of ID’s for items to include in the aggregation
  • it__not_id: list of ID’s for items to exclude from the aggregation
  • meta: array with key/value pairs to filter posts by meta values
  • terms: array with the list of term ID’s to filters posts by terms


Get aggregated stars rating for all posts/post types

<?php $_aggreation = gdrts_aggregate()->posts_by_author(
        14, array('method' => 'stars-rating')); ?>

When you run this, you will get the object with results like this:

stdClass Object
    [rating] => 4.54
    [rating_min] => 4.00
    [rating_max] => 5.00
    [votes] => 18
    [votes_average] => 2.57
    [votes_min] => 1
    [votes_max] => 3
    [items] => 7

This means that rating is aggregated from the total of 7 items. Average rating for the set is 4.54, the minimal rating for the individual item in the set was 4.0, and maximal was 5.0. Set has the total of 18 votes, and on average that is 2.57 votes per item, with 1 vote minimum and 3 votes maximum for one item.

Rate this reference

You are not allowed to rate this post.

Leave a Comment