How to Create Compact Archives in WordPress

How to Create Compact Archives in WordPress:-By default, WordPress has a widget called Archives which enables you to show monthly blog post archive links.

Now, if your blog is few years old already then this list becomes too long to show in WordPress sidebar. You can display archives as drop-down menu in sidebar but it makes them less noticeable. Today, we’ll show you how you can create compact archives that fit anywhere and look pretty much.

When and why you need compact archives in WordPress?

As we discussed earlier, the default WordPress archives widget has only limited options. Either you can display archives as long list or drop down menu.

Because of this concern, many blogs don’t show archives on their site at all. By compact creating you can show archives on your site without taking much space. You can show them on  about page or dedicated archive sections.

Adding Compact Archives in WordPress:-

The initial things you need to do is install & activate Compact Archives plugin. The plugin offers three styles to show compact archives on your site.

Style 1:- Relaxed Three-Letter Month Initials

Style 2:- Compact monthly initials

Style 3:- Numeric Block

There are several ways to easily show them on anywhere on site.

How to Create Compact Archives in WordPress

Adding Compact Archives in WordPress Pages or Posts:-

Compact Archive plugin comes with easy to use Gutenberg block called WPBeginner’s compact archives. If you’re making use of new Gutenberg editor in WordPress, then simply edit posts or pages where you want to add compact archive block.

Now the block will show in content area of your page. You can tap to enter a title for compact archive blocks and select style from block setting from right.

Adding compact archives to wordpress sidebar:-

Another place to show archive links is your blog sidebar. Compact archives plugin makes it easy to display archive links in WordPress without taking too much space in sidebar.

Simply navigate to Appearance>> Widgets page & add “Compact archives” widget to sidebar.

After that, provide a title and select style. Don’t forget to tap on save to store the changes.Now visit your site to see plugin in actions.

Display compact archives using shortcode:-

If you’re using WordPress classic editor, then you’ll not able to use the compact archive block in WordPress posts or pages.

Don’t worry! you can still add contact archive using a handy shortcode. Simply the edit the page or post where you want to display archives and add this shortcode.

[compact_archive]

This shortcode will simply display your archives. Shortcode will display contact archives in block format, you’ll use this shortcode:

[compact_archive style=”block”]

Also you can add your own HTML after and before archives. In the below shortcode, We have displayed compact archive in numeric format and wrapped around paragraph tags.

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

Display compact archives in template files:

If you’re  creating custom WordPress theme or want to show archive in theme template file then this plugin comes with handy template tags that you can use.  Simply add this template tag in your code.

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

Also there are many parameters that you can adjust:

<ul>

<?php compact_archive($style=’initial’, $before=’<li>’,

$after=’</li>’); ?>

</ul>

These same parameters you can use with shortcodes.