WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WordPress.com Popular Posts

This plugin can show the most popular articles in your sidebar, using data collected by Jetpack or WordPress.com Stats plugins.

I added the widget, but nothing shows up

Check whether the WordPress.com Stats or Jetpack plugins are installed and active. If you use WP Stats, you need at least version 1.2.

I chose to show 5 posts, but I only see 2/3...

Try to raise the value of the Magic Number (under the widget options): it will try to fetch more data from the server and should fix your issue. Too bad, this could slow down the plugin, so it would be better to enable the cache (in the options again).

I'd like to display the most popular posts per category.

Add some WPPP widgets, and then choose a different category in each one's options.

How can I integrate this plugin in my non-widget-ready theme?

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 (can be: both, posts, pages; default both)
  • format (the format of the links shown, default: <a href='%post_permalink%' title='%post_title%'>%post_title%</a>)
  • time_format (the format used with %post_time%, see Formatting Date and Time )
  • thumbnail_size (the width/height in pixels of the post's thumbnail image)
  • 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 following FAQ for instructions)
  • exclude_author (the list of authors IDs to exclude, separated by commas)
  • 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 FAQ below for info. Default 0, i.e. all categories)
  • cachename it is used to enable the cache. Please see the FAQ below.
  • cache_only_when_visitor (if enabled, it doesn't serve a cached version of the popular posts to the users logged in, default 0)
  • magic_number (set it to a number greater than 1 if you see less links than expected)

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>" );?>

You don't have to fill every field, you can insert only the values you want to change from default values.

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 with excerpt_length.
  • %post_thumbnail the thumbnail image of the post
  • %post_category% the category of the post
  • %post_comments% the number of comments a post has
  • %post_time% the date/time of the post. You can set the format with time_format.
  • %post_author% the author of the post.

I want to show the list in a dedicated page/post!

Just add a shortcode like the one below, in your page/post:

[wp_popular_posts]

Of course you can customize the list, following the instructions in the previous question. Just add your customizations after wp_popular_posts, each one separed by a space.

An example:

[wp_popular_posts title='' number=10 list_tag=ol format='<a href="%post_permalink%" title="%post_title_attribute%">%post_title%</a> (%post_views% views)<p>%post_excerpt%</p>' excerpt_length=200 cachename=popular-posts-page]

This example displays a nice top 10 list, complete with title, number of views, excerpt, and it's cached for performance.

If you specify the format parameter, be SURE you paste this into the WP page in HTML or the editor will screw up the HTML formatting in the format= parameter.

How can I enable the thumbnail feature?

You must add %post_thumbnail% to your format field, in the widget's settings. For example, you could use this format:

<a href='%post_permalink%' title='%post_title_attribute%'>%post_thumbnail%%post_title%</a>

You can customize the image size in the settings.

Note that your theme should support Post Thumbnails, and your posts should have an image set. If they don't, a default image will be displayed. You can read a guide to set the posts' thumbnail here.

However you can do this automatically for you, please read the other FAQs below.

Also note that probably the image will not look nice by default, please see below.

I added %post_thumbnail% in the format, but I don't see any image.

The thumbnail function is only compatible with WordPress 2.9+, please check your WP version. Furthermore, try to disable and re-enable the widget's cache in its options.

I added %post_thumbnail% in the format, the image are displayed but I don't like their style!

This is very theme-dependent, but a good starting point could be adding this CSS code to your `/wp-content/themes/YOURTHEME/style.css file (note that creating a Child Theme would be a nicer choice):

ul.wppp_list li {
    min-height: 65px;
    display: block;
    list-style: none outside none;
  }

  ul.wppp_list img {
    float: left;
    margin-right: 4px;
    border: 2px solid #ECEFF5;
  }

I didn't set featured images for old posts. Do I have to set them by hand?

Fortunately not, there are some nice plugins that can set the first image in the posts as featured image. One plugin could be: Auto Post Thumbnail.

How can I discover the ID of a post/page?

Log into your admin page, go to Posts or Pages; go with your mouse on your post's title, and in your status bar you should see something like this: http://YOURSITE.com/wp-admin/post.php?action=edit&post=14 Then 14 is the number you are looking for.

How can I enable the caching system when using WPPP_show_popular_posts()?

When you're using WPPP_show_popular_posts(), the caching system is not enabled. However you can easily enable it adding a cachename parameter to your settings string. You will have something like this:

<?php WPPP_show_popular_posts( "title=&number=3&cachename=topposts1" );?>

where topposts1 is a name you must choose for your list. This allows you to have different lists with different caches.

I want to change the time format!

Just set the time format as you wish. For example, if you set the time format to: d/m/Y H:i:s, you will get something like this: 21/03/2008 22:52:36. See Formatting Date and Time for further help.

I have some other issues. How can I get a debug log?

  1. Download this zip file
  2. extract it and overwrite the current /wp-content/plugins/wordpresscom-popular-posts/wppp.php file

Now, if you are using WPPP as a widget:

  1. Log in to your admin page.
  2. Go to Settings -> Popular Posts DEBUG
  3. you’ll see a long text. Copy & mail it to: frasten AATT gmail DOOTT com

If you are instead using WPPP_show_popular_posts() function for non-widget-ready themes:

  1. edit your theme files, replacing your old WPPP_show_popular_posts with WPPP_show_popular_posts_debug .
  2. you'll see the debug text in place of your usual top-posts list.
  3. Copy & mail it to: frasten AATT gmail DOOTT com

IMPORTANT: Then, for both cases (widget and function) reinstall the original version of wppp.php.

I want to translate the plugin in my language!

Now you can easily translate the plugin online here: https://translations.launchpad.net/wordpresscom-popular-posts/trunk

I'll add your translations to the plugin!

Requires: 2.8.0 or higher
Compatible up to: 3.3.2
Last Updated: 2012-11-27
Downloads: 143,239

Ratings

4 stars
4.3 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,2,2 50,2,1
100,3,3 100,4,4
67,3,2 100,1,1
100,1,1 100,2,2
100,3,3
100,5,5
100,1,1
100,3,3
100,2,2 100,1,1
100,4,4 80,5,4 50,2,1
100,1,1
100,1,1
100,1,1
100,2,2
100,1,1
67,3,2 50,2,1
33,6,2
100,2,2
100,1,1