| 开发者 |
smub
noumaan deb255 |
|---|---|
| 更新时间 | 2026年2月17日 03:51 |
| PHP版本: | 4.8 及以上 |
| WordPress版本: | 6.9.1 |
| 版权: | GPL-2.0+ |
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, Classic Editor, and WordPress widgets.
What's Next
If you like this plugin, then consider checking out our other projects:
<?php compact_archive(); ?> at the place in your template
where you want it to appear, e.g., in your sidebar:<ul> <?php if ( function_exists( 'compact_archive' ) ) compact_archive(); ?> </ul>
[compact_archive] in a page or post to display compact archives. See FAQ for shortcode parameters.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>
The shortcode [compact_archive] works just like the template tag. It accepts the following parameters:
style - Display format: initial (default), block, or numericbefore - 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[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.
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.
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"]
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.
classname attribute to shortcode for custom CSS classes.before attribute now accepts tag names without brackets (e.g., before="div").