Expanding Archives
Expanding Archives adds a widget that shows your old posts in an expandable/collapsible format. Each post is categorized under its year and month, so you can expand all the posts in a given month and year. This plugin comes with very minimal CSS styling so you can easily customize it to match your d
About this tool.
Expanding Archives adds a widget that shows your old posts in an expandable/collapsible format. Each post is categorized under its year and month, so you can expand all the posts in a given month and year.
This plugin comes with very minimal CSS styling so you can easily customize it to match your design.
JavaScript is required. No IE support.
Screenshots & previews.
Getting started.
- 01Upload expanding-archives to the /wp-content/plugins/ directory
- 02Activate the plugin through the ‘Plugins’ menu in WordPress
- 03Go to Appearance -> Widgets and drag the Expanding Archives widget into your sidebar.
Frequently asked questions.
How can I change the appearance of the widget?
The plugin does not come with a settings panel so you have to do this with your own custom CSS. Here are a few examples:
Change the year background colour:
.expanding-archives-title { background: #000000; }
Change the year font colour:
.expanding-archives-title a { color: #ffffff; } How can I limit the results to a specific category?
By default, the widget includes posts in all categories. You can add the following code to a custom plugin or a child theme’s functions.php file to limit the results to posts in a specific category:
add_filter('expanding_archives_get_posts', function(array $args) { $args['cat'] = 2; // Replace with ID of your category. return $args; }); add_filter('expanding_archives_query', function(string $query) { $category = get_category(2); // Replace with ID of your category. if (! $category instanceof \WP_Term) { return $query; } global $wpdb; return " SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year, COUNT(id) as post_count FROM {$wpdb->posts} INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id AND {$wpdb->term_relationships}.term_taxonomy_id = 2) WHERE post_status = 'publish' AND post_date <= now() AND post_type = 'post' GROUP BY month, year ORDER BY post_date DESC "; });