CountPosts v 1.0 – WordPress Plugin

Latest Version: CountPost 2.0
CountPosts V 2.0 a for latest WordPress versions from 2.5 to 2.6.2
Now it don’t count post from all users with user-level 8, (admin permissions), so it will not count visits from whole admin team, not just one admin person like older version

CountPosts V 1.1 Beta for WP 2.0

CountPosts is plugin for WordPress Blog. It’s very easy to install and use.

This plugin count visits on your blog, but not when u are log-in as admin. Also count visits for every post separated, and u know in every moment how many people read your posts. U can see what is the most read post in your blog. Also when u read your posts, CountPost won’t count your visits.

CountPost make u list of the most read post, with hits for every post separated.

Installation:

1) Add CountPost.php in Plugin folder
2) In Plugins section, click on the activate button for CountPost plugin
3) Add

  1. <?php HitThisPost(‘Hits for this post:’, ); ?>;

in index.php or single.php (It depending of your Theme you using) somewhere before comments or where ever you like. First and second attribute can be changed.
4) Add

  1. <?php mainCounter(‘Visits: : ‘, ‘ .’); ?>

in sidebar.php First attribute is print before visits number, and second is after visits number
5) Add

  1. <?php TopHitsList(); ?>

somewhere when u want to show top list of read posts.

Using TopHitsList(); function

  1. <?php function TopHitsList($beforeRead = ‘ (‘, $afterRead = ‘ ).’, $top = 5, $beforeAll = ‘<ul>’, $beforeLink =‘<li>’,
  2. $afterLink = ‘</li>’);
  1.  
  2. <?php
  3. function TopHitsList($beforeRead = ‘ (‘, $afterRead = ‘ ).’, $top = 5, $beforeAll = ‘<ul>’, $beforeLink =‘<li>’,$afterLink = ‘</li>’);
  4.  
  5.  
  6. /*$beforeAll – print before all.
  7. $afterAll – print after all.
  8. $beforeLink – print before post link.
  9. $beforeRead – print after post link and before hits.
  10. $afterRead – print after hits.
  11. $afterLink – print after $afterRead*/
  12. ?>
  13.  

Sample of using TopHitsList() function

  1.  
  2. <?php
  3. //in unnumbered list
  4. TopHitsList(‘ Read  ’,‘  times.’, $top = 5,  ‘<ul>’, ‘<li>’, ‘</li>’, ‘</ul>’);
  5.  
  6. //in numbered list
  7.  
  8. TopHitsList(‘ Read  ’,‘  times.’, $top = 5,  ‘<ol>’, ‘<li>’, ‘</li>’, ‘</ol>’);?>

Output will be something like this:
POST NAME1 Read 12 times.
POST NAME2 Read 34 times.

Older version problems:

  • Version 1.0 don’t work if your blog use Revrite Rule. Now it works even if your link structure looks like this : www.yourblog.com/blog/2006/04/04/sample-post/
  • When activate some other plugin, you had error: WordPress database error: [Duplicate column name ‘post_hits’] . This error wasn’t making any problems, but it was annoying.

Download Latest version:
Download CountPost for WordPress 1.5

Download CountPost for WordPress 2.0

Update 5. April 2006
New version 1.1 Beta is hire. I fixed some bugs in 1.0 version:

If u have any problems, suggestions for this plugin contact me.

95 Responses to CountPosts v 1.0 – WordPress Plugin
  1. Ivan Ðurđevac

    Ellen,

    Add this code into your index.php in the loop.
    More about the loop at
    http://codex.wordpress.org/The_Loop
    [code]
    < ?php
    if (is_single()) {
    TopHitsList(' Read ',' times.', 5, '

      ', '
    • ', '
    • ', '');
      }
      ?>
      [/code]

  2. Ellen

    Oke, Ivan, I will try that!
    I’m at work now, but I will let you know the result!

    Ellen

  3. Ellen

    Hi Ivan,

    It’s not working… :( I’ve read about the loop, but I don’t know exactly what to do, because nothing is happening…

    Here’s my index.php:

    “>
    “> ” rel=”bookmark”>

    ‘, ”, ”, ”);
    }
    ?>

    Edit‘));?>

    –>

  4. Ellen

    ohw… that’s not working either! ;)

    “>
    “> ” rel=”bookmark”>

    ‘, ”, ”, ”);
    }
    ?>
    Hits: ‘, ”); ?>
    Edit‘));?>

    –>

  5. Roel

    Ivan,

    thanks for your reply; I’ve used the code, but I would prefer not to show the number of times the article has been read. Right now I have:
    - article 1 (500)
    - article 2 (498)

    I would like to show:
    - article 1
    - article 2

    Would this be possible?

  6. Whisper

    I love your plugin it is exactly what I was looking for and it works wonderfully.

    I run a website for a non-profit organization, and would like to keep stats on which of our adoption listings are being veiwed most each week.

    I am going to look at this myself but I’m struggling a bit.

    Would you know a way to get it to clear the stats automatically at the end of each week so that I have fresh stats for the following week. Like say make it reset the stats on Saturday night at a certain time.

    If you could help me with the query that would accomplish this I could help create an admin page so that folks could turn the feature on or off. I’m just not good with date functions *blush*

  7. [...] CountPosts (http://www.ivandjurdjevac.com/?p=75)  [...]... timesavingexpert.wordpress.com/2006/11/05/wordpress-plugins-2
  8. SabbeRubbish

    Dear,

    The plugin is great, but I have one small comment.
    Everytime The Loop goes around (10 posts on front page for example), every post on the front page gets its post_hits incremented. Thats not really what I though it would do, so i suggest the following code change:


    function HitThisPost($before = '', $after='', $detailed_view = true) {
    global $wpdb, $table_prefix, $wp_query, $current_user;
    $p = $wp_query->post->ID;
    if ($p)
    {
    $Update = "Update " . $table_prefix . "posts set post_hits = post_hits + 1
    WHERE ID=" . $p ;
    //echo $current_user->wp_capabilities;
    //if (get_profile('user_login') != 'admin')
    if(!current_user_can('level_2') && $detailed_view)
    $wpdb->query($Update);
    $SQL = "SELECT post_hits FROM " . $table_prefix . "posts WHERE ID=" . $p;
    $red = $wpdb->get_row($SQL);
    echo $before . $red->post_hits . $after;
    }
    }

    So on the index.php you use the third argument false and on the SinglePost.php (for example from Almost Spring), we use true as the third argument.

    Let me know if you think this is interesting.

    Greetings,
    SabbeRubbish

  9. Juixe TechKnow

    Hi – I also agree with SabbeRubbish in the above comment. This is a kewl plugin but I needed a way to reveal the count in the index.php of al the posts without having the count increase for each post! I hope you add the above fix in an official release. Thanks for the plugin!

  10. MrAnderson

    Great Plugin… I’ll sugest and option page for reseting post_id… I’ve changed the post-slug of a post after it was published, so the plugin is still pointing to the old post-slug… don’t know how to solve it. Greeting

  11. Ivan Ðurđevac

    Soon i will write a new version of this plugin, and it will have more features like reseting counts for some post, and other from above comments…

    Thanks for your suggestions!

  12. Benji

    I install it but it doesnt count, everything on the db seems alright… what could be?

  13. erick

    i have this error

    Parse error: syntax error, unexpected T_FOR in /home/.monatana/todhirsch/realdealcostarica.com/wp-content/themes/oficentroweb/single.php on line 18

    and in the line 18 i put

    ;

    please if someone know why, please letme know

    10nx everybody

  14. haxxor

    I’m getting the same error as erick after upgrading to Wp 2.1.3. what is the solution? is there an update for this plugin?
    thanks

  15. search engine marketing services in spanish

    Hello Ivan,
    It seems to be a great plug-in, i have several blogs using WordPress 2.2 and 2.1.3, and I´d like to use it, but it seems that there are some problems, is there any compatibility problem with recent versions? or do I have to wait for your upgrade?
    I see that you provide an excellent support to all of your fans, I would appreciate your comments.
    Thanks.

  16. Roman

    hello, can this plugin shows top posts of the actual month? if yes, how can I modify that? thanks. Roman

  17. Meonx

    I have a problem curent instaling this plugin ata mine

  18. Peter Schwaiger

    Hi there,

    first of all – thx for the great plugin. I am just puttin up my first blog. Installed CountPost under WP2.2.1 and it works great.

    BUT – I also installed the Language Switcher WP-Plugin (http://poplarware.com/languageplugin.html) today to create a switchable English/German blog. Everything still works, but the ‘TopHitsList()’-function (as you can see here: http://www.autlawmusic.com/archiv) does not.

    I told the programmer of the LS-Plugin and this is her reply:

    “You will have to make sure that whenever the
    other plugins (in their PHP code) put information on the screen (such as post titles), that the plugins “filter” the information using the standard WordPress filters. If you are a PHP programmer, I can point you to some resources on the WordPress site to learn about filters, and you can fix the plugins. If you are not a PHP programmer, then your only recourse is to try to explain to the plugin authors that
    they should always use the standard WordPress filters when putting out information, and hope they fix it.”

    Your countPost Plugin is really very cool – so my question: Is there a chance, you make use standard WP filters in one of the next versions?

    Thx & Greetings,
    Peter

  19. problemlöser

    I know from my own experience that one only recieves bug reports and never just a pure, innocent “thank you” – but tonight I will change the game:

    Thanks for the plugin. I installed it and it just works fine!

  20. MrAnderson

    Great plugin!! I use it on my blog… only one problem… I’ve changed the permalink structure of the blog, but the CountPost database didn’t change so I’m receiving 404 error when clicking the link provided by CountPost plugin… any chance of a new version with Option Panel for rebuilding the permalink structure in CountPost database??

  21. Manele

    i just installed this plugin on my blog and i love it! thank you!

  22. MrAnderson

    I solved the problem of permalink change… you have to edit this awesome plugin and change the part where the SQL calls for “guid” field, for get_permalink() function…

    It should be like this

    echo $beforeLink , “” , $top->post_title , ““, $beforeRead , $top->post_hits , $afterRead , $afterLink;

    And problem solved… greetings

  23. MrAnderson

    echo $beforeLink , "" , $top->post_title , "", $beforeRead , $top->post_hits , $afterRead , $afterLink;

  24. Manele Noi

    Usefoul Plugin

  25. Muzica

    Thanks, i like it

  26. Rim

    Thanx from Ukrain =) Simple nice plugin

  27. sağlık

    nice good job…
    thanks

  28. www.r10.net küresel ısınmaya hayır seo yarıºması

    Nice good

  29. Frank Lucas

    WordPress: v2.3.2
    MySQL: v5.0.45-community-nt
    PHP: v4.4.7
    Server: Microsoft-IIS/6.0
    Firefox v2.0.0.11

    Plugin activates but throws error on page.

    Regards.

  30. new software

    thanks good

  31. Muzica Noua

    I have a website but i dont know how to instal a blog on him….can you help me?

  32. arabalar

    thank you for codes.

  33. SEO

    thank you

  34. hekimboard

    thanks yusufum…it is hekimboard..

  35. free java games

    nice plugin

  36. hekimboard

    thanks friends..

  37. dıs cephe

    thanks friends..

  38. free download mobimb

    thanks also

  39. Carlos José Teixeira

    Nope, doesn’t work on wp 2.6.2, chrometweaks template.
    Tryed to place it on index.php, single.php and page.php. The result is allways the same, as in index.php:

    «Parse error: syntax error, unexpected T_FOR in /home/deictorg/public_html/fractura.net/wp-content/themes/chrometweaks/index.php on line 41»

    But maybe I’m being stupid. What I’ve made was simply paste de code as follows

    ;

    to the file, under the comments php.

    Is it necessary to do anything more?

    Would you be kind to send me an e-mail regarding this issue?
    I think it’s a great tool and it’s a pitty I can’t use it.

    Regards,
    CJT

  40. Simon

    Hey Ivan, thanks for the plugin. I was wondering if I could exclude a category from the output and vice versa. How can I get in touch? Thanks,

    Simon

  41. Juliano

    Hello buddie,
    I installed this plugin long time ago in my blog and everything was doing good… until I changed my permanent links. Now the lins in the top posts list are all wrong, and I don’t know how to change this.

    Here is the page:
    http://j.ajamil.blog.br/as-100-mais-lidas

    Help, please :)

  42. ARTI

    Thanks you very much. Would you know a way to get it to clear the stats automatically at the end of each week so that I have fresh stats for the following week. Like say make it reset the stats on Saturday night at a certain time.

  43. Güvenlik Sistemleri

    thanks a lot.

  44. Marius Bancila

    This doesn’t work for 2.7.x. Since I’ve done the upgrade to this version, all my posts have 0 hits. What’s the problem?

Оставите одговор

Your email address will not be published. Please enter your name, email and a comment.

*

Можете користити ове HTML ознаке и атрибуте: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

114025 pregleda