Collapsing Archives


This is a relatively simple plugin that uses Javascript to make the Archive links in the sidebar collapsable by year and/or month. There are a number of options available, such as having the ability to link to the archive pages or not, and whether or not you want to display individual posts or not. It also supports custom post-types. There are several default styling options built-in which work well with most themes. You can also define your own custom styles.


I use this plugin in my blog at


  • Collapsing archives with default theme
  • widget options



The easiest way to use this plugin is as a widget.

After you have installed the Collapsing Archives plugin, then simply go the Appearance > Widgets section in wp-admin and add the Collapsing Archives Widget to whatever sidebar or widget section you like, and then configure to your heart’s content.


It is also possible to use the plugin on any page you like with a little bit of PHP code. Simply change the following here appropriate (most likely sidebar.php):

Change From:

     <?php wp_get_archives(); ?>

To something of the following:

     if( function_exists('collapsArch') ) {
     } else {
      echo "<ul>\n";
      echo "</ul>\n";


  'noTitle' => '',
  'inExcludeCat' => 'exclude',
  'inExcludeCats' => '',
  'inExcludeYear' => 'exclude',
  'inExcludeYears' => '',
  'sort' => 'DESC',
  'showPages' => false, 
  'linkToArch' => true,
  'showYearCount' => true,
  'expandCurrentYear' => true,
  'expandMonths' => true,
  'expandYears' => true,
  'expandCurrentMonth' => true,
  'showMonthCount' => true,
  'showPostTitle' => true,
  'expand' => '0',
  'showPostDate' => false,
  'postDateFormat' => 'm/d',
  'postDateAppenc' => 'after',
  'accordion' => 0,
  'postTitleLength' => '',
  'post_type' => 'post',
  'debug' => '0',
  • noTitle
    • If your posts don’t have title, specify a string to show in place of the
  • inExcludeCat
    • Whether to include or exclude certain categories
      • ‘exclude’ (default)
      • ‘include’
  • inExcludeCats
    • The categories which should be included or excluded
  • inExcludeYear
    • Whether to include or exclude certain years
      • ‘exclude’ (default)
      • ‘include’
  • inExcludeYears
    • The years which should be included or excluded
  • showPages
    • Whether or not to include pages as well as posts. Default if false
  • showYearCount
    • When true, the number of posts in the year will be shown in parentheses
  • showMonthCount
    • When true, the number of posts in the month will be shown in parentheses
  • linkToArch
    • 1 (true), clicking on a the month or year will link to the archive (default)
    • 0 (false), clicking on a month or year expands and collapses
  • sort
    • Whether posts should be sorted in chronological or reverse
      chronological order. Possible values:

      • ‘DESC’ reverse chronological order (default)
      • ‘ASC’ chronological order
  • expand
    • The symbols to be used to mark expanding and collapsing. Possible values:
      • ‘0’ Triangles (default)
      • ‘1’ + –
      • ‘2’ [+] [-]
      • ‘3’ images (you can upload your own if you wish)
      • ‘4’ custom symbols
  • customExpand
    • If you have selected ‘4’ for the expand option, this character will be
      used to mark expandable link categories
  • customCollapse

    • If you have selected ‘4’ for the expand option, this character will be
      used to mark collapsible link categories
  • expandYears

    • 1 (true): Years collapse and expand to show months (default)
    • 0 (false): Only links to yearly archives are shown
  • expandMonths
    • 1 (true): Months collapse and expand to show posts (default)
    • 0 (false): Only links to yearly and monthly archives are shown
  • expandCurrentMonth
    • When true, the current month will be expanded by default
  • expandCurrentYear
    • When true, the current year will be expanded by default
  • showPostTitle
    • 1 (true): The title of each post is shown (default)
  • showPostDate
    • 1 (true): Show the date of each post
  • postDateFormat
    • The format in which the date should be shown (default: ‘m/d’)
  • postDateAppend
    • after: The post date comes after the title (default)
    • before: The post date comes before the title
  • postTitleLength
    • Truncate post titles to this number of characters (default: 0 = don’t
  • post_type
    • post (default)
    • page
    • all (includes regular post types plus any custom post types – excludes
      pages, revisions, wp_nav_items, and attachments)
    • custom post type that you have registered (e.g. recipe)
  • accordion
    • When set to true, expanding one year will collapse all other years.
      Expanding one month will collapse all other months in that year
  • number
    • If using manually with more than one instance on a page, you can give
      unique ids to each instance with this option. For example, if you had
      one instance with number 1 and another with number 2, the ul for March
      2004 for number 1 would have an id of ‘collapsArch-2004-3:1’, while the
      id for number 2 would be ‘collapsArch-2004-3:2’
  • debug
    • When set to true, extra debugging information will be displayed in the
      underlying code of your page (but not visible from the browser). Use
      this option if you are having problems



This will produce a list with:
* accordion style expanding and collapsing
* shown in chronological order
* using images to mark collapsing and expanding
* exclude posts from the categories general and uncategorized


This will produce a list with:
* only posts of type ‘recipe’
* shown in chronological order
* using images to mark collapsing and expanding
* exclude posts from the categories general and uncategorized


This plugin relies on Javascript, but does degrade
gracefully if it is not present/enabled to show all of the
archive links as usual.


How do I change the style of the collapsing archives lists?

The collapsing archives plugin uses several ids and classes which can be
styled with CSS. These can be changed from the settings page. You may have to
rename some of the id statements. For example, if your sidebar is called
“myawesomesidebar”, you would rewrite the line

sidebar li.collapsArch {list-style-type:none}


myawesomesidebar li.collapsArch {list-style-type:none}

If you are using the plugin manually (i.e. inserting code into your theme),
you may want to replace #sidebar with #collapsArchList

There seems to be a newline between the collapsing/expanding symbol and the

category name. How do I fix this? =

If your theme has some css that says something like

sidebar li a {display:block}

that is the problem.
You probably want to add a float:left to the .sym class


2021 ལོའི་ཟླ 9 ཚེས 30 ཉིན།
The plugin worked flawlessly (sure, it feels like Blogger...) up to and including PHP 7.4.23. Sadly, switching to PHP 8.0 reveals a fatal flaw that breaks an entire WP site. I have deactivated the plugin, and now my WP 5.8.1 site works just fine with PHP 8.0.10
2020 ལོའི་ཟླ 5 ཚེས 28 ཉིན།
This would be a great plugin if it worked. I added the widget to a sidebar and configured it. No archives are displayed in the sidebar. Documentation is sketchy so I may be missing something.
2018 ལོའི་ཟླ 10 ཚེས 26 ཉིན།
Thanks for this free plugin
2016 ལོའི་ཟླ 9 ཚེས 3 ཉིན།
The instructions never state that you have to replace your existing Archives widget with the new Collapsing Archive widget. But it works well!
2016 ལོའི་ཟླ 9 ཚེས 3 ཉིན།
I've use this plugin for years, but there is a bug I found: In collapsFunctions.js, on the line 39 and line 51, Robert use the for click event, but the live function is removed on jQuery 1.9 [1], should use on function instead. If you do not include jquery-migrate, this plugin won't work on collapse/expand [1] I've modified the collapsFunctions.js on my local, and hope this change will merge into n next version before ` ./collapsFunctions.js:39: jQuery('#' + id + ' span.expand').live('click', function() { ./collapsFunctions.js:51: jQuery('#' + id + ' span.collapse').live('click', function() { ` after ` ./collapsFunctions.js:39: jQuery( document ).on('click', '#' + id + ' span.expand', function() { ./collapsFunctions.js:51: jQuery( document ).on('click', '#' + id + ' span.collapse', function() { `
གདེང་འཇོག 16 ཡོངས་སུ་ཀློག

བྱས་རྗེས་འཇོག་མཁན། & གསར་འབྱེད་པ།

“Collapsing Archives” is open source software. The following people have contributed to this plugin.


“Collapsing Archives” has been translated into 1 locale. Thank you to the translators for their contributions.

ཁྱེད་ཀྱི་སྐད་ཡིག་ནང་ལ་ “Collapsing Archives” ཡིག་སྒྱུར་བྱོས།

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.


2.1 (2021.06.18)

  • Compatible with WP 5.7
  • Incorporated a number of code improvements from my other collapsing plugins
  • Tested on WP 5.7.2
  • Updated documentation a bit
  • Added some screenshots and icons

2.0.5 (2017.08.17)

  • Compatible with WP 4.8
  • Cleaned up code some to reduce warnings

2.0.4 (2017.01.02)

  • Compatible with WP 4.7
  • Fixed bug with jquery compatibility
  • Removed deprecated mysql debugging info
  • Works with PHP 7

2.0.3 (2015.08.12)

  • Compatible with WP 4.3

2.0.2 (2014.09.24)

  • Fixed bug when expanding years but not showing month links, where the oldest posts were not getting displayed

2.0.1 (2014.09.05)

  • Compatible with WP 4.0

2.0 (2012.04.09)

  • now using all jquery for javascript stuff
  • added accordion option
  • added option to not use cookies
  • Fixed display issues with IE
  • Easier style handling
  • Added support for custom post types

Older versions

  • See changelog.txt