A brief how-to in response to a visitor comment.
In recent comment on my article about WordPress 2.1 Plugin Compatibility, Julie said that she was having trouble getting the Readers Post plugin to work. I added this plugin to my site a few months ago and wrote about it here. That piece didn’t include any how-to information.
What It Does
The Readers Post plugin by Stefan Groenveld is a three-trick pony that offers the following features:
readers()returns a count of the number of people who have read a post.last_posts()displays a list of the most recently read posts.hot_posts()displays a list of the post popular posts, including a reader count.
I use all three of these options on my site. But rather than go into detail about the parameters — you can find that on the plugin’s page; scroll down for English — I’ll provide the code I use as an example.
readers()
This function must be used within The Loop. (If you don’t know what the Loop is, look it up in the WordPress Codex or, better yet, buy our WordPress book, which explains it in detail.) I use it in my post “footer” to display the number of times a post has been read along with a bunch of other stuff. Here’s the code snippet for readers():
This code does two things:
?php if(function_exists('readers'))checks to see if the Readers Post plugin is installed. (Actually, it checks to see if thereaders()function is available.) If it is available,{readers('Read ',' Times'); }displays the results of thereaders()function with the simplebeforeandafterparameters I’ve provided.
The result looks something like this — I put a red box around the code’s actual output:

last_posts()
I use last_posts() in the sidebar to list the 8 most recently read posts. I find this list of posts fascinating. Each time I visit the site, I look at the list to see what people have been reading. Sometimes I’ll see an old post listed and click the link to revisit it myself. I hope other people find some of the titles intriguing and visit some of my older posts, too.
Anyway, the code I use is as follows:
This does the same thing as the code listed above for readers(), but it uses a different syntax for the conditional (if) statement. 8 is the parameter for the number of posts to display.
On my site, this code is enclosed within <ul> and </ul> tags for formatting — most templates use those tags to present information in the sidebar, but your theme may be different. I also put a heading over it to explain what it is.
The result, at this very moment, looks like this on my site’s Home page:

hot_posts()
I also use hot_posts() in the sidebar. It lists the 8 most popular posts — the ones read most. Keeping in mind how much I love stats, you can imagine how much I like this information. To me, it’s like a horse race, with certain posts racing to have the most hits. When a new post passes an old one, I’m always kind of tickled. (Yeah, I know what you’re saying. What a geek!)
Anyway, here’s my code:
Again, this code is enclosed within <ul> and </ul> tags for formatting. And since the Readers Post plugin has no way to count posts read before it was installed, I also included a note in small type that indicates when the counts started. I’ll probably remove that count sometime in the future. Here’s what it looks like on my site’s Home page:

Some Tips
If your blog doesn’t get many hits (yet), I don’t recommend using readers() or hot_posts(). The numbers they display might be depressing. I think (but am not sure) that the plugin starts counting as soon as it’s installed and activated, so you could always add these two functions at a later time and have counts displayed from the installation day rather than the first day the function is used. And site administrator visits are not counted, so you can re-read any post you like without skewing the count.
last_posts() will always be a great addition to the site, almost like a “suggested reading” list for visitors — and a re-reading list for you.
How did you get your “Recently Read” to display every post rather than just posts that have been clicked from other posts on your site? I noticed you have yours tweaked to display every page view under “Recently Read”.
All the code is above. I didn’t do anything special.