Title: Expanding Archives
Author: Ashley
Published: <strong>18 de juny de 2015</strong>
Last modified: 23 de març de 2024

---

Cerca extensions

Aquesta extensió **no s’ha provat en les darreres 3 versions majors del WordPress**.
Segurament no està mantinguda o suportada, i pot tenir problemes de compatibilitat
quan s’usa en versions recents del WordPress.

![](https://s.w.org/plugins/geopattern-icon/expanding-archives.svg)

# Expanding Archives

 Per [Ashley](https://profiles.wordpress.org/nosegraze/)

[Baixa](https://downloads.wordpress.org/plugin/expanding-archives.zip)

 * [Detalls](https://ca.wordpress.org/plugins/expanding-archives/#description)
 * [Ressenyes](https://ca.wordpress.org/plugins/expanding-archives/#reviews)
 *  [Instal·lació](https://ca.wordpress.org/plugins/expanding-archives/#installation)
 * [Desenvolupament](https://ca.wordpress.org/plugins/expanding-archives/#developers)

 [Suport](https://wordpress.org/support/plugin/expanding-archives/)

## Descripció

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.

## Captures

 * [[
 * The widget on my blog. This version has custom CSS applied.
 * [[
 * The widget on the Twenty Fifteen theme, with only the default styles applied.
 * [[
 * No widget settings – just add and save!

## Instal·lació

 1. Upload `expanding-archives` to the `/wp-content/plugins/` directory
 2. Activa l’extensió mitjançant el menú ‘Extensions’ del WordPress
 3. Go to Appearance -> Widgets and drag the Expanding Archives widget into your sidebar.

## PMF

### 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
         ";
     });
    ```

Be sure to set the ID of your category in both of the designated places (the examples
use ID `2`).

Note that the results may not update instantly, as the query to retrieve the date
periods is cached for one day. To force the query to re-run, delete this transient:`
expanding_archives_months`

### How can I specify a cut-off date?

By default, the widget will show a list of every year you’ve published posts.

If you have a lot of posts, you may wish to only show results from the last few 
years. This can be done with the following code snippet:

    ```
    add_filter('expanding-archives/earliest-date', fn() => '-4 years');
    ```

You can change `-4 years` to any value supported by [the PHP DateTime constructor](https://www.php.net/manual/en/datetime.construct.php).
This can be a relative value (as shown above), or a specific date like:

    ```
    add_filter('expanding-archives/earliest-date', fn() => '2023-01-01');
    ```

Note that the results may not update instantly, as the query to retrieve the date
periods is cached for one day. To force the query to re-run, delete this transient:`
expanding_archives_months`

## Ressenyes

![](https://secure.gravatar.com/avatar/0e367574c19400ff828e8e3b1ed6effff7e053ca20d586f8172075c27a13a476?
s=60&d=retro&r=g)

### 󠀁[Great plugin, simple yet very flexible](https://wordpress.org/support/topic/great-plugin-simple-yet-very-flexible/)󠁿

 [Roger](https://profiles.wordpress.org/erpol53/) 19 de gener de 2023

Very useful, lightweight plugin, will go in every theme and is easily customizeable
with a bit of CSS

![](https://secure.gravatar.com/avatar/79ac0574f33575066c5e7fcc978f5dad887fc5d3f43e5771c7f0b878b909844f?
s=60&d=retro&r=g)

### 󠀁[Awesome plugin!](https://wordpress.org/support/topic/awesome-plugin-1920/)󠁿

 [mairag](https://profiles.wordpress.org/mairag/) 3 de setembre de 2016

Easy to use and customize.

![](https://secure.gravatar.com/avatar/0f9679f693361ce2ceff4df17cd64345e911ee8e65e18020e97f5ad9f953204c?
s=60&d=retro&r=g)

### 󠀁[Nice but could be cleaner](https://wordpress.org/support/topic/nice-but-could-be-cleaner/)󠁿

 [asullivn](https://profiles.wordpress.org/asullivn/) 3 de setembre de 2016

It looks nice if you only have a few posts per month, but I wish you had the option
to choose whether the month will appear expanded or collapsed as a default. If you
do a post per day, opening the page with the month expanded is way too long and 
makes the sidebar look cluttered. Bullets before each post would also make it look
cleaner.

![](https://secure.gravatar.com/avatar/4048c4f50726e97a73e90dfa31e96affa3639fa3fda546963626dd980b9d2112?
s=60&d=retro&r=g)

### 󠀁[cleanly executed](https://wordpress.org/support/topic/cleanly-executed/)󠁿

 [hughc](https://profiles.wordpress.org/hughc/) 3 de setembre de 2016 1 resposta

Took a punt, as no demo offered (yr blog has no sidebar, AFAIK), and works nicely.
Element classes assist styling.

 [ Llegiu totes les 6 ressenyes ](https://wordpress.org/support/plugin/expanding-archives/reviews/)

## Col·laboradors i desenvolupadors

«Expanding Archives» és programari de codi obert. La següent gent ha col·laborat
en aquesta extensió.

Col·laboradors

 *   [ Ashley ](https://profiles.wordpress.org/nosegraze/)

“Expanding Archives” s’ha traduït a 2 configuracions regionals. Gràcies als [traductors](https://translate.wordpress.org/projects/wp-plugins/expanding-archives/contributors)
per les seves aportacions.

[Traduïu «Expanding Archives» a la vostra llengua.](https://translate.wordpress.org/projects/wp-plugins/expanding-archives)

### Interessats en el desenvolupament?

[Navegueu pel codi](https://plugins.trac.wordpress.org/browser/expanding-archives/),
baixeu-vos el [repositori SVN](https://plugins.svn.wordpress.org/expanding-archives/),
o subscriviu-vos al [registre de desenvolupament](https://plugins.trac.wordpress.org/log/expanding-archives/)
per [fisl de subscripció RSS](https://plugins.trac.wordpress.org/log/expanding-archives/?limit=100&mode=stop_on_copy&format=rss).

## Registre de canvis

#### 2.1.0 – 23 March 2024

 * New: Added support (via a filter) for specifying a cut-off date. See readme FAQ
   for details.

#### 2.0.2 – 3 February, 2022

 * Refactor: Posts are now retrieved via a custom REST API endpoint, instead of 
   the default. This allows developers to more easily filter the query arguments
   for retrieving posts.

#### 2.0.1 – 31 January, 2022

 * Fix: Only showing a max of 10 posts in a month. Now it will show up to 100.

#### 2.0 – 23 January, 2022

 * Dev: Plugin has been rewritten (should be backwards compatible).
 * Dev: Removed jQuery dependency (and dropped IE support).
 * Dev: Remove Font Awesome spinner in favour of vanilla CSS.
 * Fix: Invalid HTML when the site has no posts.

#### 1.1.1

 * Added filters that allow developers to easily modify the archive list.

#### 1.1.0

 * Added a new option in the widget where you can choose to auto expand the current
   month or not.

#### 1.0.5

 * Use transient for database query that fetches all the months.

#### 1.0.4

 * Added `xhrFields: { withCredentials: true }` to ajax call.

#### 1.0.3

 * Changed the month URLs to use get_month_link() instead of building them manually.
 * Tested the plugin with WordPress 4.4 beta.

#### 1.0.2

 * Tested with WordPress version 4.3.

#### 1.0.1

 * Month names are now displayed using date_i18n() instead of date() so they will
   translate.

#### 1.0.0

 * Initial release.

## Meta

 *  Versió **2.1.0**
 *  Darrera actualització **fa 2 anys**
 *  Instal·lacions actives **3.000+**
 *  Versió del WordPress ** 3.0 o posterior **
 *  Provada fins a **6.4.8**
 *  Versió del PHP ** 7.4 o posterior **
 *  Idiomes
 * [English (US)](https://wordpress.org/plugins/expanding-archives/), [Japanese](https://ja.wordpress.org/plugins/expanding-archives/),
   i [Swedish](https://sv.wordpress.org/plugins/expanding-archives/).
 *  [Traduïu a la vostra llengua](https://translate.wordpress.org/projects/wp-plugins/expanding-archives)
 * Etiquetes
 * [archives](https://ca.wordpress.org/plugins/tags/archives/)[navigation](https://ca.wordpress.org/plugins/tags/navigation/)
   [posts](https://ca.wordpress.org/plugins/tags/posts/)[sidebar](https://ca.wordpress.org/plugins/tags/sidebar/)
   [widget](https://ca.wordpress.org/plugins/tags/widget/)
 *  [Vista avançada](https://ca.wordpress.org/plugins/expanding-archives/advanced/)

## Valoracions

 4.7 sobre 5 estrelles.

 *  [  4 valoracions de 5 estrelles     ](https://wordpress.org/support/plugin/expanding-archives/reviews/?filter=5)
 *  [  2 valoracions de 4 estrelles     ](https://wordpress.org/support/plugin/expanding-archives/reviews/?filter=4)
 *  [  0 valoracions de 3 estrelles     ](https://wordpress.org/support/plugin/expanding-archives/reviews/?filter=3)
 *  [  0 valoracions de 2 estrelles     ](https://wordpress.org/support/plugin/expanding-archives/reviews/?filter=2)
 *  [  0 valoracions de 1 estrelles     ](https://wordpress.org/support/plugin/expanding-archives/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/expanding-archives/reviews/#new-post)

[Visualitzeu totes les ressenyes](https://wordpress.org/support/plugin/expanding-archives/reviews/)

## Col·laboradors

 *   [ Ashley ](https://profiles.wordpress.org/nosegraze/)

## Suport

Teniu quelcom a dir? Necessiteu ajuda?

 [Visualitza els fòrums de suport](https://wordpress.org/support/plugin/expanding-archives/)

## Feu una donació

Voleu ajudar a què l’extensió millori?

 [ Feu una donació a aquesta extensió ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=L2TL7ZBVUMG9C)