• I’m searching for a plugin which displayes how many times a post was read. I don’t know where to begin searching, of what words to search for in the codex (e.g. x times read post” doesn’t give a usuable result…)

Viewing 13 replies - 1 through 13 (of 13 total)
  • This is the one you want:
    https://weblogtoolscollection.com/archives/2005/03/14/top-10-plugin/

    If you run into problems, post back here and I’ll copy how I’m placing that code.

    Thread Starter selder2

    (@selder2)

    I’m not sure that is what I’m looking for… I looked at some of the examples in the comments, and can’t find what I’m searching.

    In a standard WordPress beneath an “post” (entry, article) there’s a small rectangle with the following text (e.g.):

    ———–
    This entry was posted on Thursday, November 3rd, 2005 at 8:28 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
    ————

    I would like to add the text:

    ————
    this entry was read 10 times
    ————

    where 10 is the number of times someone browsed to that entry …

    Thread Starter selder2

    (@selder2)

    Ahha! I just found a blog where it does display “X times read” … I’ll start there and dig deeper :p

    Thread Starter selder2

    (@selder2)

    Ok, i’m lost, totally ??

    I have 3 index.php files, and neither contain the line

    <?php } } else { // end foreach, end if any posts ?>

    I have the following index.php’s:

    /home/www/htdocs/index.php
    /home/www.htdocs/wordpress/index.php
    /home/www.htdocs/wordpress/wp-content/themes/milk/index.php

    In what file do I need to search for that code?

    Im lost too… care to enlighten a bit more? What are you trying to do in the index.php?

    @estjohn,

    selder2 is looking up index.php because of the following direction given in the top10.php (plugin script):
    Open your index.php and find this line:
    <?php } } else { // end foreach, end if any posts ?>
    And place this line just above that:
    no permalinks:
    <?php if ($p > 0) { add_count($p);}?>
    using permalinks:
    <?php if($id > 0) { add_count($id);} ?>

    I think the code snippet should be inserted in “single.php” file of the theme, but not on the index.php, since the number of instances the individual post is called has to be counted.

    And the following is to be placed in the “index.php” at the place where you want the number of visits to be shown:
    <?php show_post_count($post->ID, $before="(Visited ", $after=" times)"); ?>

    I too struggled with this script, but succeeded finaly with the help of Podz!

    Thread Starter selder2

    (@selder2)

    I’ll quote the little procedure from the top10.php

    —————
    ## HTML INSTRUCTIONS ##
    Open your index.php and find this line:
    <?php } } else { // end foreach, end if any posts ?>
    And place this line just above that:
    no permalinks:
    <?php if ($p > 0) { add_count($p);}?>
    using permalinks:
    <?php if($id > 0) { add_count($id);} ?>
    Now place this code where you want your top10 posts to show up (outside the wp-loop):
    <?php show_pop_posts(); ?>
    ## UPDATE ##
    Want to see how many times a post has been viewed? Follow the instructions below:
    Then find this line to your index.php:
    <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>
    And add this line right below it (or anywhere around it):
    <?php show_post_count($post->ID, $before="(Visited ", $after=" times)"); ?>

    ———————-

    This is what I want to do, but I don’t know in what file to add those lines…

    Postscript:

    This page gives ample details.

    Index.php.
    Top of the Loop is
    <?php while (have_posts()) : the_post(); ?>

    End of the Loop is
    <?php endif; ?>

    Both those statements are in the ‘whiteasmilk’ theme.

    Thread Starter selder2

    (@selder2)

    Mmm … I think I have a big problem.

    In my index.php in /home/www/htdocs/wordpress I don’t use the loop. I commented it out, and I use a static frontpage (as explained in the codex). So there’s no one who’s visiting that index.php file, because all posts are accessed directly from the frontpage…

    You can see what I mean :

    https://www.damn.be <- static frontpage
    https://www.damn.be/weblog <- index.php which is never visited

    Darn… I’ll search some more if I can’t put that <?php if($id > 0) { add_count($id);} ?> code somewhere else.

    Thread Starter selder2

    (@selder2)

    Ok, I think I got it, because when I browse that new SQLtable, I see that every time I visit an entry, the number increases.

    One more problem…

    I’ve added

    <?php if($id > 0) { add_count($id);} ?>

    to my single.php.

    But when I try to browse to a single entry, I get the following error:

    Parse error: parse error, unexpected T_STRING in /home/geert/www/htdocs/weblog/wp-content/themes/milk/single.php on line 52

    Thread Starter selder2

    (@selder2)

    And line 52 is this:

    <?php show_post_count($post->ID, $before=a€?Views(a€?, $after=a€?)a€?); ?>

    I’m no PHP wizard, an don’t know mysql, but that seems correct to me? I don’t understand why that error T_String is displayed :/

    Thread Starter selder2

    (@selder2)

    replacing the a€? by ” solved the problem ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘“times read” on posts in WordPress’ is closed to new replies.