Title: Compact Archives
Author: Syed Balkhi
Published: <strong>2008 年 5 月 9 日</strong>
Last modified: 2026 年 2 月 16 日

---

搜尋外掛

![](https://ps.w.org/compact-archives/assets/banner-772x250.png?rev=2480251)

![](https://ps.w.org/compact-archives/assets/icon-256x256.png?rev=2480251)

# Compact Archives

 由 [Syed Balkhi](https://profiles.wordpress.org/smub/) 開發

[下載](https://downloads.wordpress.org/plugin/compact-archives.4.1.1.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/compact-archives/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/compact-archives/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/compact-archives/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/compact-archives/#developers)

 [技術支援](https://wordpress.org/support/plugin/compact-archives/)

## 外掛說明

The built-in WordPress archives widget is great for new blogs, but it doesn’t look
as good for more established blogs like [WPBeginner](https://www.wpbeginner.com/).
Compact Archives displays the monthly archive of posts in a more compact form rather
than the usual long list. It can be shown as a compact block suitable for the body
of an [archives page](https://www.wpbeginner.com/wp-tutorials/how-to-create-an-archives-page-in-wordpress/):

    ```
    2009: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    2008: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    2007: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    ```

or in an even more compact form to fit a sidebar:

    ```
    2009: J F M A M J J A S O N D
    2008: J F M A M J J A S O N D
    2007: J F M A M J J A S O N D
    ```

or something in between:

    ```
    2009: 01 02 03 04 05 06 07 08 09 10 11 12
    2008: 01 02 03 04 05 06 07 08 09 10 11 12
    2007: 01 02 03 04 05 06 07 08 09 10 11 12
    ```

Compact Archive plugin works seamlessly with [Gutenberg Block Editor](https://www.wpbeginner.com/beginners-guide/how-to-use-the-new-wordpress-block-editor/),
[Classic Editor](https://www.wpbeginner.com/plugins/how-to-disable-gutenberg-and-keep-the-classic-editor-in-wordpress/),
and WordPress widgets.

#### What’s Next

If you like this plugin, then consider checking out our other projects:

 * [OptinMonster](https://optinmonster.com/) – Get More Email Subscribers with the
   most popular conversion optimization plugin for WordPress.
 * [WPForms](https://wpforms.com/) – Best Drag & Drop WordPress Form plugin (over
   1 million active installs).
 * [MonsterInsights](https://www.monsterinsights.com/) – See the Stats that Matter
   and Grow Your Business with Confidence. Best Google Analytics Plugin for WordPress.
 * [SeedProd](https://www.seedprod.com/) – Jumpstart your website with the #1 Coming
   Soon & Maintenance Mode Plugin for WordPress.
 * [WP Mail SMTP](https://wordpress.org/plugins/wp-mail-smtp/) – Improve email deliverability
   for your contact form with the most popular SMTP plugin for WordPress.

Visit [WPBeginner](http://www.wpbeginner.com/) to learn from our [WordPress Tutorials](http://www.wpbeginner.com/category/wp-tutorials/)
and find out about other [best WordPress plugins](http://www.wpbeginner.com/category/plugins/).

Like all plugins, Compact Archives is only available for self-hosted WordPress sites.
So YES you need to [switch from WordPress.com to WordPress.org](http://www.wpbeginner.com/wp-tutorials/how-to-properly-move-your-blog-from-wordpress-com-to-wordpress-org/)
in order to use this plugin on your WordPress site. For more details, see the infographic
on [Self hosted WordPress.org vs Free WordPress.com](http://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/)

If you like this plugin, then please leave a good rating. For support just ask the
questions here in the support forum.

#### Credits

This plugin was originally created by [Rob Marsh](https://profiles.wordpress.org/robmarsh/)
and [Aldolat](https://profiles.wordpress.org/aldolat/) added a widget for it. WPBeginner
adopted the plugin and took the responsibility of keeping it updated.

## 螢幕擷圖

 * [[
 * Compact archives displayed in block layout
 * [[
 * Gutenberg block

## 適用於區塊編輯器

這個外掛提供 1 個可供 Gutenberg/區塊編輯器使用的區塊。

 *   WPBeginner

## 安裝方式

 1. Upload the plugin folder to your /wp-content/plugins/ folder.
 2. Go to the **Plugins** page and activate the plugin.
 3. Put `<?php compact_archive(); ?>` at the place in your template
     where you want
    it to appear, e.g., in your sidebar:
 4.     ```
        <ul>
            <?php if ( function_exists( 'compact_archive' ) ) compact_archive(); ?>
        </ul>
        ```
    
 5. You can also use shortcode `[compact_archive]` in a page or post to display compact
    archives. See FAQ for shortcode parameters.
 6. There is also a Compact Archives Widget which can be used to display compact archives
    in sidebar or any widgetized area.

## 常見問題集

### How Do I Get the Different Layouts?

The template tag, `compact_archive`, has some parameters:

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

If $style == ‘initial’ (the default) the display will fit into a sidebar:

    ```
        2009: J F M A M J J A S O N D
        2008: J F M A M J J A S O N D
        2007: J F M A M J J A S O N D
    ```

If $style == ‘block’ the display will be wide enough to fill the main column of 
a page:

    ```
        2009: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
        2008: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
        2007: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    ```

If $style == ‘numeric’ the display will use month numbers:

    ```
        2009: 01 02 03 04 05 06 07 08 09 10 11 12
        2008: 01 02 03 04 05 06 07 08 09 10 11 12
        2007: 01 02 03 04 05 06 07 08 09 10 11 12
    ```

$before and $after wrap each line of output. The default values make
 each line 
of the archive into a list item:

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

### How do I get different layouts using shortcode?

The shortcode `[compact_archive]` works just like the template tag. It accepts the
following parameters:

 * `style` – Display format: `initial` (default), `block`, or `numeric`
 * `before` – Wrapper tag: `li` (default), `p`, `div`, or `span`. Can be written
   with or without angle brackets.
 * `classname` – Custom CSS class(es) to add to the container

Examples:

    ```
    [compact_archive style="block"] - Display archives in block format.

    [compact_archive style="numeric" before="p"] - Display in numeric form, wrapped in paragraph tags.

    [compact_archive before="div" classname="my-archive custom-class"] - Wrap each line in a div with custom CSS classes.
    ```

### How do I get different layouts using Compact Archive Widget in Sidebar?

Compact Archive comes with a sidebar widget located Appearance -> Widgets. Drag 
and drop Compact Archives Widget to your sidebar. The widget has three option fields.
You can provide your widget a title if you want or leave it blank. You can choose
a display layout from Select the Style option. It has three layout choices to choose
from which are initials, block, and numeric. Tansform text option can be left to
No Transformation or you can tansform text style to UPPERCASE or Capitalize.

### Is There Any Scope for CSS Styling?

The year links at the start of each line are wrapped in  tags while months with 
no posts are wrapped with so you can differentiate them visually using your style
sheet.

You can also use the `classname` attribute in the shortcode to add custom CSS classes:

    ```
    [compact_archive classname="my-custom-archive"]
    ```

### What if My Site is in Another Language?

The plugin chooses month names and abbreviations according to the language locale,
WPLANG, set in wp-config.php.

Compact Archives also honours whatever kind of permalink pattern you have set.

## 使用者評論

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

### 󠀁[Great! But….](https://wordpress.org/support/topic/great-but-147/)󠁿

 [dadiocoleman](https://profiles.wordpress.org/dadiocoleman/) 2021 年 4 月 2 日

Very simple and works, however, the title attribute is stuck on 2001. I’d suggest
the plugin author fix this officially by changing the hardcoded 2001 to $year on
line 97 of inc/compact-archives.php.

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

### 󠀁[The best archive plugin](https://wordpress.org/support/topic/the-best-archive-plugin/)󠁿

 [face0ff](https://profiles.wordpress.org/face0ff/) 2021 年 3 月 11 日

Works fine. Can be easily adjusted. Love it!

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

### 󠀁[Love this Archive Plugin](https://wordpress.org/support/topic/love-this-archive-plugin/)󠁿

 [Clarence Johnson](https://profiles.wordpress.org/picpu/) 2020 年 5 月 17 日

Does the job.

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

### 󠀁[Quick and simple plugin](https://wordpress.org/support/topic/quick-and-simple-plugin-2/)󠁿

 [digitaleyecandy](https://profiles.wordpress.org/digitaleyecandy/) 2020 年 1 月
23 日 2 則留言

Can be customized to filter on CATEGORY with a few changes.

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

### 󠀁[Cool](https://wordpress.org/support/topic/cool-382/)󠁿

 [marcodimitri1](https://profiles.wordpress.org/marcodimitri1/) 2016 年 9 月 3 日

Very cool plugin. Thank you

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

### 󠀁[Very good plugin – a small tweak for localization](https://wordpress.org/support/topic/very-good-plugin-a-small-tweak-for-localization/)󠁿

 [Deceneus](https://profiles.wordpress.org/deceneus/) 2016 年 9 月 3 日

The plugin works great! If u plan to use the plugin for a different language website
and don’t want to rely on the WPLANG variable (deprecated after WP 4.0) you should
edit the plugin and simply replace the existent localization DIR to something like
this: setlocale(LC_TIME, "ro_RO"); // set localization language where ro_RO is the
code for Romanian, fr_FR for French, etc.

 [ 閱讀全部 9 則使用者評論 ](https://wordpress.org/support/plugin/compact-archives/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Compact Archives〉的開發相關工作。

參與者

 *   [ Syed Balkhi ](https://profiles.wordpress.org/smub/)
 *   [ Noumaan Yaqoob ](https://profiles.wordpress.org/noumaan/)
 *   [ Andrei Surdu ](https://profiles.wordpress.org/_smartik_/)

〈Compact Archives〉外掛目前已有 1 個本地化語言版本。 感謝[全部譯者](https://translate.wordpress.org/projects/wp-plugins/compact-archives/contributors)
為這個外掛做出的貢獻。

[將〈Compact Archives〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/compact-archives)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/compact-archives/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/compact-archives/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/compact-archives/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/compact-archives/)。

## 變更記錄

#### 4.1.1

 * Improved input validation for shortcode parameters.
 * Enhanced output sanitization.
 * Added URL escaping for archive links.
 * New: Added `classname` attribute to shortcode for custom CSS classes.
 * New: Shortcode `before` attribute now accepts tag names without brackets (e.g.,`
   before="div"`).

#### 4.1.0

 * New: Support the block based Widget editor introduced in WordPress 5.8.

#### 4.0.0

 * New: Improve caching of database queries by using the WordPress object cache.
 * Enhancement: Use WordPress Core date internationalization.
 * Enhancement: Use language files generated by translate.wordpress.org.
 * Fix: Styling fixes for block editor archive block.
 * Minimum version of WordPress updated to 4.7.

Earlier changelog entries can be found in changelog.md.

## 中繼資料

 *  版本 **4.1.1**
 *  最後更新 **3 個月前**
 *  啟用安裝數 **2,000+**
 *  WordPress 版本需求 ** 4.8 或更新版本 **
 *  已測試相容的 WordPress 版本 **6.9.4**
 *  PHP 版本需求 ** 5.6 或更新版本 **
 *  語言
 * [English (US)](https://wordpress.org/plugins/compact-archives/) 及 [Russian](https://ru.wordpress.org/plugins/compact-archives/).
 *  [將這個外掛本地化為你的母語版本](https://translate.wordpress.org/projects/wp-plugins/compact-archives)
 * 標籤:
 * [archive](https://tw.wordpress.org/plugins/tags/archive/)[archives](https://tw.wordpress.org/plugins/tags/archives/)
   [widget](https://tw.wordpress.org/plugins/tags/widget/)[yearly archive](https://tw.wordpress.org/plugins/tags/yearly-archive/)
 *  [進階檢視](https://tw.wordpress.org/plugins/compact-archives/advanced/)

## 評分

 5 星，滿分為 5 星

 *  [  9 個 5 星使用者評論     ](https://wordpress.org/support/plugin/compact-archives/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/compact-archives/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/compact-archives/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/compact-archives/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/compact-archives/reviews/?filter=1)

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

[查看全部使用者評論](https://wordpress.org/support/plugin/compact-archives/reviews/)

## 參與者

 *   [ Syed Balkhi ](https://profiles.wordpress.org/smub/)
 *   [ Noumaan Yaqoob ](https://profiles.wordpress.org/noumaan/)
 *   [ Andrei Surdu ](https://profiles.wordpress.org/_smartik_/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/compact-archives/)