Most read posts
A developer-friendly plugin to count post reads and list most read content
Only all time most read posts will be counted by default and reads made by logged-in user or more than once per hour by same user in same post will be ignored. These defaults can be changed using filters.
Handcrafted with love at Digitoimisto Dude Oy, a Finnish boutique digital agency in the center of Jyväskylä.
Table of contents
Please note before using
This plugin is not meant to be "plugin for everyone", it needs at least some basic knowledge about php. Plugin is in development for now, so it may update very often and things might change.
Most read posts is released under the GNU GPL 2 or later.
This plugin does not have settings page or provide anything visible on front-end. Settings can be changed with filters listed below.
Plugin introduces two new functions to get most read posts.
get_most_popular_posts_ids returns array containing ids of five posts, behaviour can be altered with parameters.
Both functions accepts three parameters.
$period (string) (optional) Which period of most read posts to receive. Possible values are year, month and week. Default value is null, which equals to all-time.
$args (array) (optional) If period is set, this parameter is used to set what year and month or week to use. Set array with period as key and wanted time as value. Default value is empty array, which equals to current year, month and week. For example, following array would return most read posts for 2015-09;
array( 'year' => '2015', 'month' => '09' ).
$query_args (array) (optional) Is merged to arguments set by plugin and forwarded to WP_Query. With this you can set post type or result count with
post_per_page for example. Default value is empty array.
Plugin functionality can be changed with hooks.
dmrp_dont_count_logged_in_users when set to false, count also reads made by logged-in users. It's recommended to use
dmrp_count_for_post_types by default reads are counted only for posts. Change it by passing array of wanted post types for this filter.
dmrp_cookie_timeout by default reads more than once per hour by same user in same post will be ignored. Change the time by passing wanted cookie timeout in milliseconds or disable this functionality by passing
dmrp_count_weekpass true to count most read posts also by week. It's recommended to use
dmrp_count_month pass true to count most read posts also by month. It's recommended to use
dmrp_count_year pass true to count most read posts also by year. It's recommended to use
To use this plugin with composer, run command
composer require digitoimistodude/dude-most-read-posts in your project directory or add
"digitoimistodude/dude-most-read-posts":"dev-master" to your composer.json require.
If you have ideas about the plugin or spot an issue, please let us know. Before contributing ideas or reporting an issue about "missing" features or things regarding to the nature of that matter, please read Please note section. Thank you very much.