Easy Popular Posts Plugin for WordPress

While I was working on my new theme for thisismyurl.com I came across the need to publish a series of popular posts in the side bar and so I put together a simple plugin for WordPress. The tool works like most WordPress theme calls and features:

  • Customizable number of links returned
  • Customizable before and after to ensure you can display the results
  • The ability to echo or return results
  • Let’s you control how popular a post should be

To use the plugin, install it to your WordPress website and edit your theme files by placing the following code:

General results
Without passing any parameters, the plugin will return ten results or fewer depending on how many posts you have.

[source lang="php"]<?php popularPosts();?>[/source]

Specific number of results
If you would like to return a specific number of results as your maximum:

[source lang="php"]<?php popularPosts(‘count=10′);?>[/source]

Altering the before and after values
By default the plugin wraps your code in list item (

  • ) tags but you can specify how to format the results using the following code:
    [source lang="php"]<?php popularPosts(‘before=<p>&after=</p>’);?>[/source]

    Echo vs. Return
    Finally, if you’d like to copy the results into a variable you can return the results as follows:

    [source lang="php"]<?php popularPosts(‘echo=false’);?> [/source]

    Minimum Comments
    To ensure you only return truly popular articles, you can limit the returned posts to posts with a minimum number of comments

    [source lang="php"]<?php popularPosts(‘comments=10′);?> [/source]

    Download the plugin

    Support forums are now online! If you have any questions, please visit http://forums.thisismyurl.com.

  • 9 Responses to “Easy Popular Posts Plugin for WordPress”

    1. suraj says:

      thx for the sharing plugin, nice stuff, thx christ..

    2. fruey says:

      Hello

      I’d really like to know more about how this plugin calculates most popular. I’m not aware of post views being native to WordPress, but perhaps it is?

      Also little note: the article has HTML entities in full in my browser (Firefox) so they look broken… (> is > in the article itself). Also, you reference randomPosts as the function name, but isn’t that another plugin you wrote?

      Finally – I spotted your plugin on my Wordpress dashboard filed under “newest plugins”.

      Regards,

      -Fruey

      fruey’s last blog post..Woolies is going, going, gone

    3. baron says:

      Works great, thank you

    4. Any idea if you can add multiple parameters? For example: echo=false and count=4

      I tried ‘echo=false;count=4′ with no luck

      Brennan McEachran’s last blog post..Public Transit

    5. Jestin Joy says:

      Thanx for the plugin

      Jestin Joy’s last blog post..AA battery powered netbook from NorhTec Corporation

    6. @Brennan, you sure can!

      To add multiple parameters to the plugin separate them with an & symbol. For example:

      ‘comments=10&echo=false’

    7. [...] Añade al blog los artículos mas populares, y los resultados pueden mostrarse de muchas formas y ha sido probado  con los scripts populares caché. [...]

    8. ifmp says:

      “To use the plugin, install it to your WordPress website and edit your theme files by placing the following code:”

      Place it where?

    9. Hi Iggy, you can place it anywhere in the theme HTML. So for example, to place it in the footer, just place add < ?php popularPosts('comments=10');?> in the footer.php file and away you go! Keep in mind that you have to do a little HMTL formating to make it look great.

    Leave a Reply