WordPress.com Popular Posts

WordPress.com Popular Posts integrates with WordPress.com Stats plugin, providing a widget to show the most viewed posts.

Installation

  • From v2.0.0, WordPress 2.8 is required. If you are using an older version of WordPress, use v1.3.5 of this plugin.
  • Install WordPress.com Stats plugin (required at least v1.2!!!)
  • Download WordPress.com Popular Posts
  • Extract the files in the .zip archive, and upload them (including subfolders) to your /wp-content/plugins/ directory
  • Activate the plugin through the ‘Plugins’ menu in WordPress
  • Place the widget where you like in your sidebars
  • Enjoy!

Themes Integration

If your theme supports widgets, you can place the widget named ‘Popular Posts’ where you want.

If it doesn’t, put this code inside the file sidebar.php, in your theme files:

<?php if (function_exists('WPPP_show_popular_posts')) WPPP_show_popular_posts(); ?>

Optionally you can add some parameters to the function, in this format:

name=value&name=value etc.

Possible names are:

  • title (title of the widget, you can add tags (e.g. <h3>Popular Posts</h3>) default: Popular Posts)
  • number (number of links shown, default: 5)
  • days (length of the time frame of the stats, default 0, i.e. infinite)
  • show (what you want to show; it can be: both, posts, pages; default is both)
  • format (the format of the links shown, default:
    <a href='%post_permalink%' title='%post_title%'>%post_title%</a>

    )

  • excerpt_length (the length of the excerpt, if %post_excerpt% is used in the format)
  • title_length (the length of the title links, default 0, i.e. unlimited)
  • exclude (the list of post/page IDs to exclude, separated by commas. Read the FAQ for instructions)
  • cutoff (don’t show posts/pages with a view count under this number, default 0, i.e. unlimited)
  • list_tag (can be: ul, ol, none, default ul)
  • category (the ID of the category, see the FAQ for info. Default 0, i.e. all categories)
  • cachename (it is used to enable the cache. Please read the FAQ).

You can use these special markers in the format value:

  • %post_permalink% the link to the post
  • %post_title% the title the post
  • %post_title_attribute% the title of the post; use this in attributes, e.g.
    <a title='%post_title_attribute%'...
  • %post_views% number of views
  • %post_excerpt% the first n characters of the content. Set n in the widget options.
  • %post_category% the category of the post
Example

If you want to show the widget without any title, the 3 most viewed articles, in the last week, and in this format: My Article (123 views) you will use this:

<?php WPPP_show_popular_posts( "title=&number=3&days=7&format=<a href='%post_permalink%' title='%post_title_attribute%'>%post_title% (%post_views% views)</a>" );?>
Shortcodes

If you want to include the list in a particular page or post, you can use shortcodes. Please read the FAQ for further info.

FAQ

Please read other updated FAQ here.

Changelog

You can read the whole changelog on the project page.

Download

Download
Download latest version of WordPress.com Popular Posts
for WordPress 2.8+

or v1.3.5 for WordPress < 2.8

License

WordPress.com Popular Posts is released under a GPL v3 license.

This plugin required many hours of development. If you like this plugin, then buy me a coffee!

  • #1 scritto da Vera Marie Badertscher
    circa 10 mesi fa

    I tried to follow the directions to discover the number that identifies a post. Hovering over the title in the Post list in admin only gets “edit title of post” There is no number.

    The list of posts numbers the posts 1-XXX, with the latest addition being 1, so it changes each time you add a post, so that does not work. :-(

    Is it because I have changed the url format of my posts so they do not use the WP format–but instead just use the title I assign?

    I really would like to eliminate some of my posts (like contests) from the count and would like to know how.

    Otherwise this is a great tool. (Y) Hope you can help with my problem. :-S (I use widgets, by the way)

    Grazie.

  • #2 scritto da Iorya
    circa 10 mesi fa

    Hi mate,

    Great plugin u made, very handy. Thank you

    I have some problems tho using it without the widget. Sometimes it displays the content of category sometimes it just shows it empty, even if in blogs stats shows that the category has several items.

    So basically some categories post are not displayed not even one, and some display only 3 or 4 from 5 posts requested. What can i do?

    Thanks

  • #3 scritto da Blutarsky
    circa 10 mesi fa

    Something changed with the latest version of stats… Now stats_get_csv throws an error… :-(

    Permanent cache option (no time limit) would be great also for bad stats.com behavior!! :-)

  • #4 scritto da Frank Kim
    circa 10 mesi fa

    Hi,

    I love your plugin.

    I recall though that there used to be an option so that the number of post views for the popular posts is only displayed to the administrator. But that option seems to have disappeared.

    Did you remove that option or did I just imagine it?

    Thanks,
    Frank

  • #5 scritto da Frank Kim
    circa 10 mesi fa

    Love your plugin.

  • #6 scritto da david
    circa 9 mesi fa

    Hi, I’m having problems getting this plugin to show results.

    I downloaded the wppp – debug file and it shows that I’m not receiving some important info, post_id, post_title, and the correct permalink.

    See here (i replaced my real website witha fake one for posting here):

    [0] => Array
    (
    [post_id] =>
    [post_title] =>
    [post_permalink] => http://mywebsite.com/blog
    [views] => 32
    )

    [1] => Array
    (
    [post_id] =>
    [post_title] =>
    [post_permalink] => http://mywebsite.com/blog
    [views] => 7
    )

    [2] => Array
    (
    [post_id] =>
    [post_title] =>
    [post_permalink] => http://mywebsite.com/blog
    [views] => 4
    )

    ETC…

    Checking :
    Checking :
    Checking :
    Checking :
    Checking :
    Checking :
    After cleaning, top_posts is:
    Array
    (
    )

  • #7 scritto da Jean-Paul Horn
    circa 9 mesi fa

    Hi Frasten,

    Is there any special reason why you don’t use the summarize function for get_csv_stats? Isn’t it more accurate to get the most popular posts of the last month?

    $top_posts = stats_get_csv( 'postviews', "days={$instance['days']}&limit=-1&summarize=1" );

    I made this change in wppp.php and the output of WPPP (finally) reflects the values I see when I use WP-Stats-Dashboard > Top Posts in last 30 days (or either period).

    Would love to see this in a future version 8-)

  • #8 scritto da giapox
    circa 8 mesi fa

    Very nice plugin.
    I think that is very important to have some most popular posts in our blogs.
    Thank you very much! :-$

  • #9 scritto da Joe
    circa 8 mesi fa

    Error when I try to uninstall v2.2.0 from wp 2.8.6
    ===quote===
    Parse error: syntax error, unexpected ‘)’, expecting T_PAAMAYIM_NEKUDOTAYIM in /home/themepar/public_html/wp/wp-content/plugins/wordpresscom-popular-posts/uninstall.php on line 2
    ===/quote===

    • #10 scritto da frasten
      circa 8 mesi fa

      @Joe: thank you for reporting. I’ve fixed this in the development trunk. You’ll see it in the next stable version.

  • #11 scritto da Nick Aster
    circa 8 mesi fa

    Guys – how can this plugin be reset periodically? Is there a way to tell it to only take a week’s worth of data, for example?

  • #12 scritto da frasten
    circa 8 mesi fa

    @Nick: sure, you must go under the widget settings, and set “The length (in days) of the desired time frame” to 7.

  • #13 scritto da Nick Aster
    circa 8 mesi fa

    Hmm… I have this thing hard coded into a template.. this is all I see: “

    Might as well be chinese, is there a way to stick a time setting in there somehow?

    Thanks!

  • #14 scritto da Nick Aster
    circa 8 mesi fa

    Crap, code won’t paste in comment… but it’s a bunch of PHP calling the plugin

  • #15 scritto da frasten
    circa 8 mesi fa

    @Nick Aster: Hi, can you please mail that output to frasten ATTTT gmail DDOOTT com?

  • #16 scritto da Musical Instruments (Anthony)
    circa 8 mesi fa

    Hello,

    For some strange reason this plugin will only show 1 link. It happens now and then, i find i have to go and reset the widget, turn on or off the cache, and then BINGO it’s fixed again. But why does it keep doing this?