gdrts_aggregate()->posts_by_term()

gdrts_aggregate()->posts_by_term(
        $term_id, $args = array())

Description

Calculate aggregated rating for all posts assigned to specified term by ID. 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

  • $term_id: valid term 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
  • authors: array with the¬†list of author ID’s to filters posts by terms

Examples

Get aggregated stars rating for all posts/post types for term with ID 2:

<?php $_aggreation = gdrts_aggregate()->posts_by_term(
        2, array('method' => 'thumbs-rating')); ?>

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

stdClass Object
(
    [rating] => 4.00
    [rating_min] => -1.00
    [rating_max] => 3.00
    [votes] => 9
    [votes_average] => 2.25
    [votes_min] => 1
    [votes_max] => 4
    [items] => 4
    [up_average] => 1.00
    [down_average] => 1.00
    [up_total] => 3
    [down_total] => 1
)

Aggregation by thumbs rating adds extra columns for UP and DOWN votes, so you have additional values in the returning object.

0
0
101
Rate this reference

You are not allowed to rate this post.

Comments

Leave a Reply