gdrts_aggregate()->posts_by_author()

gdrts_aggregate()->posts_by_author(
        $author_id, $args = array())

Description

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.

Parameters

  • $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

Examples

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.

0
0
100
Rate this reference

You are not allowed to rate this post.

Comments

Leave a Reply