Taken over from Igor Kromin
This tutorial shows you how to use the LastEntries plugin and the PostViews plugin to see at a glance how many views the entries have had. This hack requires the PostViews plugin to be enabled.
Changed the file fp-plugins/lastentries/plugin.lastentries.php as follows:
Note that the first and last lines shown here are already in the file, so only the lines between the comments are relevant:
$link = get_permalink($id); // --- new code: reads out file from PostViews plugin --- $dir = entry_dir($id); if (!$dir) return; $f = $dir . '/view_counter' . EXT; $v = io_load_file($f); if ($v === false){ $v = 0; } // --- end new code: reads out file from PostViews plugin --- $string .= '<li>';
Then, a few lines further, the line directly above the $count++
line must be changed as follows:
// --- modified line below: adding the number of views --- $string .= "<a href=\"{$link}\">{$entry['subject']} ({$v})</a></li>\n"; $count++; // <-- existing code, do not modify
The result is something like this:
The entry view count is shown in brackets next to the entry name.