Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Create Compact Archives in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Create Compact Archives in WordPress

After a few years of blogging you will see how a WordPress archive can quickly get out of hand. What you need is a way to compress everything so that your posts are easier to find. Although we have already shown you how you can customize the display of WordPress archives in your sidebar, today we are going to use a plugin called Compact Archives for WordPress.

Compact Archives as displayed on WPBeginner

There are three ways you can use this plugin. The first involves a widget that you can place in your sidebar, secondly you can use shortcode in your posts and pages, lastly you can use template tags inside your theme files.

Before we do anything else though, install and activate the Compact Archives Plugin. The first method we are going to go over is the widget method.

Using The Compact Archives Widget

To use the widget method, you need to go to Appearance » Widgets. There you will see Compact Archives widget in the available widgets. You need to drag and drop Compact Archives Widget to your sidebar.

Compact archives widget

The widget will allow you to choose a style for your compact archives and enter a widget title. You can also choose to transform the initials to uppercase. Save your widget settings and preview your site.

Using Shortcodes to Display Compact Archives

To display compact archives inside a post, or a page, you can use these shortcodes:


This shortcode will simply show your compact archives. The shortcode accepts the style, before, and after parameters. To display your compact archives in block, you will use this shortcode:

[compact_archive style="block"]

Using before and after parameters, you can add HTML that you would want to appear before and after the compact archives. In the following shortcode, we have displayed the compact archive in numeric format and wrapped it around paragraph tags.

[compact_archive style="numeric" before="<p>" after="</p>"]

Displaying Compact Archives in Custom Templates

If you want more control over where the archives should go, then you can manually insert the code into your template files. We have seen these used on custom archive pages which can be created using custom WordPress page templates. Wherever you want it to appear insert the following code:

<ul> <?php compact_archive(); ?> </ul>

There are also some parameters that you can adjust

compact_archive($style='initial', $before='<li>', $after='</li>');

These are the same parameters that you can change using the widget. For example, $style == 'initial' will would display only month name initials and should fit right inside a sidebar. Using $style == 'block', the display will fit the main column of a page. Using $style == ‘numeric’, the months will be displayed numerically.

If you are manually adjusting the code you can also change the $before and $after parameters which determine what code will wrap each line of output (default is list item).

Styling your Archive

Months with no posts in them are wrapped in

<span class="emptymonth"></span>

so you can target them in your CSS file and make it seem as if they are faded into the background our otherwise less visually significant than the months that do have posts.

We hope you this article helped you create compact archives in WordPress. Please leave your comments or join us on Twitter.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Amy Sue says:

    The “By Date” portion of Compact Archives isn’t working on my blog. I’m wondering if that’s because I had to move my blog to a new web host, or did I mess something up in it? I know enough html/css to be dangerous but usually code via the “trial and error and error and error” method so I probably messed something up…

  2. Hariharakumar says:

    This one works best for default posts. My blog has custom posts I want to display them as well in compact archives. What should I do now?

  3. Dave2 says:

    This invaluable plugin fails with the latest update… and takes WordPress with it! Can’t even get to the admin screen unless the plugin has been deactivated.

    Warning: is_readable() []: open_basedir restriction in effect. File(XXX) is not within the allowed path(s): (XXX/wp-includes/l10n.php on line 481

  4. Dan says:

    Please update this plugin. It seems to cause numerous update issues for other plugins now because it hasn’t been updated in over two years.

  5. Vince says:

    This plug-in hasn’t been updated in two+ years, and in particular hasn’t been updated to get rid of the deprecated-as-of-4.3 old constructor calling. Nor have you responded to any of the support requests in the last year.

    Are you still supporting this plugin?

    • WPBeginner Support says:

      Yes. The plugin is now updated and tested with the latest version of WordPress.

  6. Ameya says:


    I’d like to know if there is anything special in this plugin? I use SRG Clean Archives. Do you know anything about this plugin? Is it better or I should use the one you suggested?


    • Editorial Staff says:

      Never used the plugin you are suggesting, so cannot tell you which one is better. This is the one that we use. It is up to you to make the final decision.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.