[Resolved] Fix for Popular Posts showing only 9-10 posts
Jetpack’s Popular Posts widget has a known bug where only 9-10 posts are shown, regardless of how high the desired number is set or how many posts were viewed during the last two days. This was e.g. discussed here but incorrectly marked as “resolved”. The workaround proposed there shouldn’t do anything. Below follows the explanation of what I found, and how I fixed it on my installation.
First, the stats module’s top views always include the front page. But Jetpack’s widget doesn’t show that if it’s the usual list of recent posts rather than an edited page. So you’ll have to increment your desired count by one to begin with: specify 11 to show 10 entries in the widget.
Second, there’s a bona fide bug in this PHP file:
Line 225 in function get_by_views($count) hard-codes the total number of popular entries fetched from the stats module to 10, rather than passing the specified $count:
$post_view_posts = stats_get_csv( ‘postviews’, array( ‘days’ => 2, ‘limit’ => 10 ) );
This is the fixed line, and with it the Popular Posts widget works correctly on my installation, modulo the front page issue described above:
$post_view_posts = stats_get_csv( ‘postviews’, array( ‘days’ => 2, ‘limit’ => $count ) )
- The topic ‘[Resolved] Fix for Popular Posts showing only 9-10 posts’ is closed to new replies.