Forum Moderators: coopster

Message Too Old, No Replies

Want to display number of views of blog posts

wanted: code to display # of views of 100 most popular posts

         

richards1052

6:29 am on Oct 6, 2005 (gmt 0)

10+ Year Member



I've seen a Drupal blog which lists the number of times a post has been viewed. I discovered that WordPress (my platform) has 2 such plugins, but they only feature the top 5 or top 10 posts. What I'd like is a list of the top 25, 50 or 100 posts. I don't care whether the data displays within the blog or whether only I can view it.

One of the moderators at the WP forum posted this obscure reply which only contains this code:

$results = $wpdb->get_results("select postnumber, cntaccess from mostAccessed ORDER BY cntaccess DESC LIMIT 1000");

Since he's not replying to any questions of mine, can anyone help me figure out what this code does, where it should be installed & how it would display the data within the blog interface? I also assume the "LIMIT 1000" should read "LIMIT 100?"

Thanks for any help you can provide.

coopster

1:22 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't know how much help I can be as I am not a WP user but I can at least explain the query statement for you ...

You are correct, the LIMIT clause is a MySQL/Postgresql-specific keyword that returns only that number of rows after processing the query. WP is using some form of data abstraction class to run it's querys and return result sets. You would need to process the result set just as you do any other query within the WP appication(s).

richards1052

5:52 am on Oct 8, 2005 (gmt 0)

10+ Year Member



Thanks for yr reply. I studied the plugins a little more & discovered that the one I was contemplating installing actually counts SE crawl hits along with human hits. I can't really understand why anyone would want to count crawl hits if you want to know how many people are viewing your posts. I certainly don't. SO I've got to wait till I find a plugin that only counts human hits.

Jaunty Edward

9:18 am on Oct 8, 2005 (gmt 0)

10+ Year Member



Hi,

even I don't know if this will help you or not....but this is the code that I use to find out if the user is human or bot(over 90% perfect)

$browser = $HTTP_USER_AGENT;
$terms = "bot";

if (eregi($terms, $browser)) {
// this visitor is bot don't update hits.
}else {
// this visitor is human update hits.
}

I don't know if you will be able to put it in your code.

Thanks
Bye

richards1052

10:34 am on Oct 8, 2005 (gmt 0)

10+ Year Member



thanks for that code. I'm not good enough with code to figure out how to modify the existing plugin to include yours. But I can ask around the WP blog world to see if folks can help me.