Create an archive of articles by category
Create the page archives.php
By using your favorite HTML editor - such as Dreamweaver or Notepad, create a new page that you save under the name: archives.php.
Insert code
- <? php
- / *
- Template Name: Archives Page
- * /
- >
- ; ?> <? php get_header ();?>
- a href = "<?php the_permalink() ?>" title = "<?php the_title(); ?>" >< ?php the_title ( ) ?> par catégories </ a ></ h2 > <H2> <a href = "<? Php the_permalink ()>" title = "<? Php the_title ();?>"> <? Php the_title ()?> By categories </ a> </ h2>
- <? php
- get_categories ( ) ; $ cats = get_categories ();
- $cats as $cat ) { foreach ($ cats as $ cat) (
- . $cat -> cat_ID ) ; query_posts ( 'showposts = 1000 & cat ='. $ cat -> cat_id);
- >
- ?php echo $cat -> cat_name ; ? ></ h2 > <H2> <? Php echo $ cat -> cat_name;> </ h2>
- <Ul>
- ( have_posts ( ) ) : the_post ( ) ; ?> <? php while (have_posts ()): the_post ();?>
- "font-weight:normal !important;" >< a href = "<?php the_permalink() ?>" >< ?php the_title ( ) ; ? ></ a > - Commentaires ( <?php echo $post -> comment_count ?> ) </ li > <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 ();?>
Title of the page
- <? php
- / *
- Template Name: Archives Page
- * /
- >
This piece of code shows the name of the page. Very useful to find them easily!
Thus, for the change online, via the WordPress editor, go to your WordPress administration panel, click the Appearance tab and then click Theme Editor.
In the list of files, then you should find archives.php.
Determination of the number of items to display
- . $cat -> cat_ID ) ; query_posts ( 'showposts = 1000 & cat ='. $ cat -> cat_id);
1 The number 000 refers to the number of items to display on the page. Depending on his blog, it will therefore adjust this number.
After some time, we may also consider cutting the page in 2 but know that it is better not to keep one even if it can reach a huge size.
Indeed, it is easier to search via Ctrl + F on a single page rather than several.
Change the page title
- a href = "<?php the_permalink() ?>" title = "<?php the_title(); ?>" >< ?php the_title ( ) ?> par catégories </ a ></ h2 > <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 there is a level 2.
You can modify to suit: Change level title (h1, h3 or h4), remove the permalink, and so on.
Implementation and compliance with the style and structure of the page
The code provided above is gross of any formatting. If you insert it as is, you will surely not the desired result due to the presence of non <div> tag.
You must indicate <div> tags needed. To do this, you can breathe in the index.php or single.php.
Again, look for tags or "> <div class=" <div "> id=" you learn about the CSS classes used in your pages articles.
You can also create a new CSS class specific to your archive page. In this case, open the style sheet in your theme - if you are uncomfortable with such changes, make a copy of your files themes.
Tags structure and formatting 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 like FileZilla or extension Firefox FireFTP.
For more information about using an FTP client, I refer you to the WordPress codex (in french).
Creating the Archive page in WordPress
To create a new page in your blog, go to the Write tab and then click Page of your WordPress administration panel.
Down completely in the bottom of the page to reach the module template page. In the dropdown, select Archives.
Finally, give a title to the page - for example, Archives, and then publish without adding additional text.
Appendices
I recommend:
- The article by jbj on the establishment of an archives page for the WordPress theme;
- The Codex WordPress Francophone;
And you, friends, readers, how did you choose to display your archive page? How did you personally?
Related Articles
Create an archive of articles by category | Maigret's Blog ...
Create an archive page is often not a trivial task. Indeed, there are many ways to list your items, but also your categories: by date, alphabetically, etc.. Therefore, we will see how credit ...
Create an archive of articles by category ...
Create an archive page is often not a trivial task. Indeed, there are many ways to list your items, but also your categories: by date, alphabetically, etc.. Therefore, we will see how credit ...
Create an archive of articles by category ...
- Do you like this article? Vote for him on Blogmemes.fr! Create an archive page is often not a trivial task. Indeed, there are many ways to list your items, but also your categories: by date, alphabetical order ...
[...] You have presented a model of archives page for your WordPress blog, we will now see how to create another page template on, this time the [...]
[...] Creating a page archive of articles by category | Maigret's Blog [...]
[...] Source of the article, read on: Maigretsblog.com / ... [...]
[...] The same way as an archive page, we need to create a page template that our home page of the forum. I am based on [...]
Create an archive of articles by category | Maigret's Blog ...
Create an archive page is often not a trivial task. Indeed, there are many ways to list your items, but also your categories: by date, alphabetically, etc.. Therefore, we will see how credit ...
[...] My blog is built on the Wordpress platform. With the (very good) tutorial proposed by Maigret, I had already established the "Blogmap" which displays the archive [...]



























In my view, the organization of the archives by category is already more attractive and above all much more ergonomic than the one proposed by default.
Thank you very much for this tutorial.
@ Yancilane: you quite right, the model proposed by WordPress Archives is based on the sequence of articles. However, while such a choice is good for a blog of news, it is much harder for a blog theme - for example.
@ all: this is Yancilane to me for advice via email to set up its own archive. From there was born this tutorial and hope it will be useful for all
I spotted an extension (which unfortunately the development is stopped) entitled Live extended archive.
The visual is very nice from what I saw, and it seems simple to configure and implement. No code to enter, except to create the static page.
http://www.sonsofskadi.net/extended-live-archive/
I will test it also on my todo list ...
@ agatzebluz: I had already heard about this plugin but I've never tried it.
However, why do not you do a tutorial on your blog?
This article was not intended originally to make plugins archive management in WordPress, but I'm ready for you to make a link to any article on the topic if the desire t'en dit
I take you to the word LOL
Once 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 that time.
Thank you for the proposal.
After you create an archive by category ", I opted for something more traditional with the plugin http://www.schloebe.de/wordpress/simple-yearly-archive-plugin/
Maigret thank you for this code.
I just added the sidebar.
It remains for me to create one. Finished css to adjust my content to my desires
A +
@ PataTy: fun!
Long ago I made an archive http://azur.ironie.org/archives very convenient to find my own old notes!
For against, I have trouble to keep the tab selected on the archives page. The fault in the loop that changes the last page read and therefore get_footer () does not know on what page it is to apply the class "current" tab. : - /
The trick is to read the archives before footer (). Provided of course that it is useful to your theme!
Thank you for the tip!
Up at me and very useful to find items
Bonne continuation
PhilC @: thank you to you!
Thank you for this information.
@ antiquarian books: thanks for your visit!