Date based period rating query object

If you need to get the rating list but limit it to the specific date period, plugin includes rating query object where you can supply date range to limit the query results.

This object is very similar to main query object, and all settings are the same, so check it out here. The only difference are two extra parameters:

  • from: start of the query period
  • to: end of the query period

Both parameters can be either timestamps or dates.

Usage Examples

Here are few examples for the query object.

// Get top 10 thumbs rating posts ordered by UP ratings
// With date period set to whole month of January 2017
$args = array(
  'from' => '2017-01-01 00:00:00',
  'to' => '2017-01-32 23:59:59',
  'method' => 'thumbs-rating',
  'limit' => 10,
  'orderby' => 'up',
  'entity' => 'posts',
  'name' => 'post'
);
$ratings = new gdrts_core_query_period();
$results = $ratings->run($args);
// Get top 5 stars rating posts, by selected authors and with listed terms
// With date period from the start of the year, until the start of the current day
$args = array(
  'from' => '2017-01-01 00:00:00',
  'to' => 'today',
  'method' => 'thumbs-rating',
  'entity' => 'posts',
  'name' => 'post',
  'object' => array(
    'author' => array(1, 3, 10),
    'terms' => array(5, 7, 53),
  )
);
$ratings = new gdrts_core_query_period();
$results = $ratings->run($args);
Rate this article

You must be logged in to rate this.

0
0
52

Comments

Leave a Reply