Page d'accueil du Codex en français - Télécharger WordPress en français
Les utilisateurs francophones se retrouvent sur le site WordPress-Francophone, notamment sur son forum d'entraide.
So you want a single page with links to all your archived entries, arranged just so to form the main gateway into your blog's past. With the WordPress 1.5 theme system, you can create template files to customize this archive gateway for each theme you use.
Or, maybe you're just wondering how to use the archives.php template file that's included with the WordPress Default Theme.
This article describes both those things. The method outlined here can also be used to make other specialized pages that are integrated with the WordPress theme system: a links page, site index, or anything else your heart desires.
To set up a separate archive index in a way that plays with the Version 1.5 theme system, you'll need to create it as a Page, and assign it a special template.
Start off with a simple template called archives.php, stored in your theme's directory. The WordPress Default Theme includes such a template, and it makes a good starting point.
Technically, the template can be called almost anything (see these two lists for names you should not use; these are special file names WordPress reserves for specific purposes). However, using a standard name for your template will make it easier to change your blog's theme or distribute your theme and template to the WordPress community. It's also possible to display a large archive index using one of the all-purpose templates (like index.php or category.php) and the is_page function, but again, taking advantage of the theme system's modularity makes it easier for others (and for you!) to edit your template later.
For more information on creating templates, see Template Tags, particularly wp_get_archives.
Upload the archives.php in your theme directory (wp-content/themes/themename/). Then from the Admin Panel, Write > Write Page, and choose Add a New Page:
Upload the archives.php in your theme directory (wp-content/themes/themename/). Then from the Admin Panel, Write > Write Page
In the sidebar open the //Page templates// box, and select the //Archives// template. After saving it you will see a new item in your pages list, click on it, and enjoy!
There are a variety of techniques to customize your Archive Index page. Some involve incorporation of plugins or PHP code to create customized lists of archived posts, and others provide more interesting ways of displaying your archives.
You can set your archives up to be displayed by the year, such as:
Archives
To list your archives by year instead of by month, use the following code, in which a query to the database is made to collect and sort the posts by year, then display them as links with the get_year_link() template tag:
<ul><li><h2>Archives</h2> <ul> <?php $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC"); foreach($years as $year) : ?> <li><a href="<?php echo get_year_link($year); ?> "><?php echo $year; ?></a></li> <?php endforeach; ?> </ul> </li></ul>
For versions of WordPress before 2.1, use this for your $years query:
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC");
If you're using Permalinks, WordPress will generate a new set of rewrite rules for your new Page. You may need to update your .htaccess file by hand, if WordPress is unable to do so automatically. See Using Permalinks for more information.
These automatic rules are based on your Page title or "slug": If your Page is named Archive Index, you'll be able to see it at http://example.net/your-wordpress-dir/archive-index/.
If your archive index Page has a slug that's the same as part of your permalink structure - e.g., your Page is named Archives, and your permalinks are set up as /archives/%post-id%/ or /archives/%year%/%monthnum%/%day%/%postname%/ - WordPress will create conflicting rewrite rules. This can cause your monthly/category archives to be displayed using your archive index template.
There are two ways to avoid this problem: