Most Popular Categories by Posts

Most Popular Categories by Posts is a WordPress plugin that allows you to list your blog’s most popular categories based on the number of posts assigned to those categories within a user-configurable time period. What a mouthful. Basically, it allows you to display the categories with the most posts this week, this month, this year, etc.

For example, if you chose to display the most popular categories in the past 30 days, and in the past 30 days, you had posted the most articles (let’s say 20 posts) to Category A and the second most articles (let’s say 18 posts) to Category B, the plugin would place Category A at the very top of the list, followed by Category B, and so on.

Demo / Screenshot

  • Sorry, no demo available, but here’s a screenshot of the most popular categories on blogHelper for the last 30 days (i.e. from 1st to 30th August, 2006):
    MPC Plugin Screenshot

Features

  • Page independent
    Just like your normal category listing, you can place the list of your most popular categories in any template you like.
  • Configurable
    If you want to, you can choose how many days of posts the plugin should take into account, how many popular categories to show, and whether or not the number of posts are shown. You can even modify the title of the output block and the various layout tags used (e.g. ul, li, div).
  • Simple installation and no file modifications required
    All primary options are handled by passing variables through the template tag. There is no need to modify plugin files (unless you want to)

Installation

  1. Download Most Popular Categories by Posts and extract the zip archive file.
  2. Upload popular-categories.php to your /wp-content/plugins/ directory.
  3. Activate the plugin in your blog’s Manage Plugins panel.
  4. Edit your theme templates according to the usage instructions below via your blog’s Theme Editor panel.

Usage

  1. Edit Templates:
    • Standard: In any of your templates (e.g. Main Index, Page Template), use the template tag zm_popular_categories() wherever you want the list to appear.
    • Custom: Follow the same instructions as for Standard usage, but use a modified template tag following this structure: zm_popular_categories ($no_of_days, $show_title, $limit, $show_number_of_posts, $custom_title, $pre_item_tag, $post_item_tag, $pre_list_tag, $post_list_tag, $pre_no_of_posts_tag, $post_no_of_posts_tag).
      • $no_of_days: By default, the plugin lists the most popular categories for the past 7 days. If you want to show more or less, enter the number you want.
      • $show_title: By default, the “Most Popular Posts This Week:” title is not shown. If you do want to show it, put 1.
      • $limit: By default, only the 5 most popular categories are shown. If you want to show more or less, enter the number you want.
      • $show_no_of_posts: By default, the number of posts assigned to each category within your selected time period is shown. To turn number of posts off, put 0.
      • $custom_title: By default, the title of the Recent Child Pages block is “Most Popular Posts This Week:” (if $show_title is set to 1). Change this as you see fit.
      • $pre_item_tag: By default, each item is pre-pended with a <li> tag. Change this as you see fit.
      • $post_item_tag: By default, each item is post-pended with a </li> tag. Change this as you see fit.
      • $pre_list_tag: By default, the entire list is pre-pended with a <ul> tag. Change this as you see fit.
      • $post_list_tag: By default, the entire list is post-pended with a </ul> tag. Change this as you see fit.
      • $pre_no_of_posts_tag: By default, the number of posts in each category is pre-pended with a <span> tag. Change this as you see fit.
      • $post_no_of_posts_tag: By default, the number of posts in each category is post-pended with a </span> tag. Change this as you see fit.
  2. Edit Stylesheet:
    • By default, the list of most popular categories comes unstyled. You can style it using your blog’s primary stylesheet though.
      • The entire block is wrapped with a “div” of class “zm_pop_cats“.
      • By default, the list is an unordered list with no class or id - though this can be modified as you see fit.
      • By default, each item is a standard list item - though this can be modified as you see fit.
      • Number of posts in each category are wrapped by a “span” of no class or id.

Download

Changelog

  • v0.1: Plugin first released.

To-Do

  1. Implement results cache.
  2. Allow user-configurable date range (i.e. beginning and end date), rather than just last XX days.
  3. Allow the display of title (with permalink) and date of most recent post in most popular categories.

54 Comments

Leave a Reply