Creating a page archive of articles by category
Categories: Wordpress
Send article
Print Article
Create an archive page is often not a trivial matter. Indeed, there are many ways to list your articles but also your categories: by date, alphabetically, and so on. That is why we will see how to create an archive page which will list all of your articles which will be sorted by categories and for your blog WordPress.
Creation of the page archives.php
With the help of your favorite HTML editor - for example, Dreamweaver or notebook, create a new page that you save as the following: archives.php.
Insertion code
<? php / * Template Name: Archives * /?> <? php get_header ();> <h2> <a href = "<? php the_permalink ()?>" title = "<? php the_title (); ?>"><? php the_title ()?> by categories </ a> </ h2> < ? php $ cats = get_categories (); foreach ($ cats as $ cat) (query_posts ( 'showposts = 1000 & cat ='. $ cat-> cat_ID);> <h3> <? php echo $ cat-> cat_name;? > </ h3> <ul> <? php while (have_posts ()): the_post ();> <li style="font-weight:normal !important;"> <a href = "<? php the_permalink () ?>"><? php the_title ();> </ a> - Comments (<? php echo $ post-> comment_count ?>)</ li> <? php endwhile;?> </ ul> <? php )?> <? Php get_footer ();> Explanations and possible changes
Name of the page
<? php / * Template Name: Archives * /?> This piece of code indicates the name of the page. Very useful to find them easily!
Thus, for the change online via the publisher WordPress, go to your hotel WordPress panel, click the Appearance tab and then editor theme.
In the list of files, then you should find archives.php.
Determination of the number of items to be displayed
query_posts ( 'showposts = 1000 & cat ='. $ cat-> cat_ID); The number 1 000 means the number of items to be displayed on the page. Depending on his blog, it is necessary therefore to adjust that number.
After a certain time, we may also consider cutting page 2 but know that it is better not to keep one even if the latter can reach a disproportionate size.
Indeed, it is easier to carry out a search via Ctrl + F on one page rather than several.
Change the page title
<h2> <a href = "<? php the_permalink ()?>" title = "<? php the_title (); ?>"><? php the_title ()?> by categories </ a> </ h2> In this example, the page title is Archives by category. This is linked to the page in question and this is a level 2.
You can change it at your convenience: change the level of title (h1, h3 even h4), abolition of permalien, etc..
Implementation and compliance with the style and structure of page
The code is provided the highest gross of any formatting. If you insert it as it stood, you will surely not the desired result because of the presence of non-tag <div>.
You must therefore show the tags <div> necessary. To do this, you can breathe on the page index.php or single.php.
Again, look for beacons <div class=" "> or <div id=" "> you learn about the CSS classes used in your pages articles.
You can also create a new class CSS specific to your archive page. In this case, open the style sheet in your theme - if you're uncomfortable with such changes, make a copy of your files themes.
The tags structure and formatting are to be added between the header (header) and footer (footer):
<? php get_header ();> <? php get_footer ();>![]()
Online file archives.php
The most common solution is to use an FTP client as FileZilla or extension Firefox, FireFTP.
For more information on the use of an FTP client, I refer you to codex WordPress (french).
Creation of the page Archives in WordPress
To create a new page in your blog, go to the Write tab and then click on your page panel hotel WordPress.
Get off quite at the bottom of the page to reach the module page template. In the drop-down list, select Page archives.
Finally, give a title page - for example, Archives, and then publish without adding additional text.
Appendices
I recommend:
- The article by Jbj on creating an archive page for its theme WordPress;
- The codex WordPress francophone;
And you, friends, readers, how did you choose to display your archive page? How did you personally?





























August 15, 2008 at 3:03
In my opinion, the organization of archives by category is already more attractive and above all much more ergonomic than that proposed by default.
Thank you very much for this tutorial.
August 15, 2008 at 3:40
@ Yancilane: you quite right, the model proposed by WordPress archives is based on the sequence of articles. But then that such a choice is good for a blog topics, it is much less for a blog themes - for example.
@ all: it Yancilane who asked me advice via mail to create its archive page. From there was born this tutorial and hope it will be useful for all
August 16, 2008 at 1:32
I spotted an extension (unfortunately whose development is arrested) extended entitled Live archive.
The design is very nice that I've seen, and it seems easy to set up and put in place. No code to enter, except create the static page.
http://www.sonsofskadi.net/extended-live-archive/
I'll try it, is also on my todo List…
August 16, 2008 at 1:44
On the other hand, why do not you do a tutorial on your blog?
This article was not intended to cause submit plugins management of archives in WordPress, but I am ready to to make you a link to a possible article on the topic if the desire expressed worry
August 16, 2008 at 2:15
I take you at your word LOL
As soon as I have a few minutes to set up a ton of things I must do to improve my blog, I'll do a tutorial.
I will keep you aware at the time.
Thank you for the proposal.
August 27, 2008 10:11
After creating an archive page "by category", I opted for something more classical with the plugin http://www.schloebe.de/wordpress/simple-yearly-archive-plugin/
August 31, 2008 11:02
Maigret Thank you for this code.
I just added the sidebar.
It remains for me to create one. Css to finish my content to adapt to my desires
A +
August 31, 2008 at 11:30
September 5, 2008 at 8:35
A long time ago that I made a page "archives" http://azur.ironie.org/archives very convenient to find my own old banknotes!
By cons, I galéré to keep tab selected archives on this page. The fault in the loop, which amends the last page read and therefore get_footer () No one knows more about what page it is to implement the class "current" tab. : - /
The trick is to read the "archives" just before footer (). Provided of course that it is useful to your theme!