Maria’s Guides

Support and additional material for readers of books, articles, and digital media by Maria Langer.


Random Book Cover #1Random Book Cover #2Random Book Cover #3Random Book Cover #4Random Book Cover #5Random Book Cover #6Random Book Cover #7Random Book Cover #8Random Book Cover #9

How I Use the Readers Post Plugin

Posted on March 5th, 2007 at 7:12 am · 2 Comments
Filed in: RSS WordPress Books   

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():

<?php if(function_exists('readers')) {readers('Read ',' Times'); } ?>

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 the readers() function is available.) If it is available,
  • {readers('Read ',' Times'); } displays the results of the readers() function with the simple before and after parameters I’ve provided.

The result looks something like this — I put a red box around the code’s actual output:

The readers() function in action

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:

<?php if (function_exists('last_posts')): ?>
&nbsp;&nbsp;&nbsp;<?php last_posts(8); ?>
<?php endif; ?>

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:

The last_posts() function in action

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:

<?php if (function_exists('hot_posts')): ?>
&nbsp;&nbsp;&nbsp;<?php hot_posts(8); ?>
<?php endif; ?>

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:

The last_posts() function in action

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.

→ 2 Comments • Read 539 Times
Add to Del.icio.usAdd to Del.icio.us • Technorati ThisTechnorati This • Digg ThisDigg This • Stumble ItStumble it! • Twit ThisTwit This