Creating a page archive of articles by category

Categories: Wordpress
Envoyer l’article Send article Imprimer l’article Print Article
(2 vote (s), average: 5 out of 5)

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:

And you, friends, readers, how did you choose to display your archive page? How did you personally?

If you liked this ticket, do not hesitate to subscribe to my RSS!
This article was published Friday, August 15, 2008 at 9:02 and is filed under Wordpress. You can follow comments through the RSS 2.0. You can leave a comment, or trackback from your own site.

Related Articles

Promote this article:

  • Facebook
  • Digg
  • Technorati
  • StumbleUpon
  • Google
  • Scoopeo
  • BlogMemes Fr
  • TwitThis
  • Wikio FR
  • del.icio.us
  • blogmarks
  • BlogMemes

13 reviews for "Create a page archive of articles categorized"

  1. Yancilane said:

    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.

  2. Maigret said:

    @ 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 :)

  3. agatzebluz said:

    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…

  4. Maigret said:
    @ agatzebluz: I had already heard about this plugin but I've never tried it.

    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 ;)

  5. agatzebluz said:

    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.

  6. - An Li said:

    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/

  7. PataTy said:

    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 +

  8. Maigret said:
    @ PataTy: the pleasure!
  9. David (Azur Dev) said:

    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! ;-)

Trackbacks

  1. www.tomateo.com:

    Creating a page archive of articles categorized | Maigret's Blog…

    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 credit…

  2. tapemoi.com:

    Creating a page archive of articles categorized…

    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 credit…

  3. www.blogmemes.fr:

    Creating a page archive of articles categorized…

    -- Like this article? Vote for him on Blogmemes.fr! 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, order alphabét…

  4. Creating a page of links in WordPress | Maigret's Blog:

    [...] You have presented a model of page archive for your blog WordPress, we will now see how to create another page template on, this time, the [...]

Leave a comment




* Required field.
French flagChinese (Simplified) flagEnglish flagGerman flagSpanish flagJapanese flagRussian flag

Survey

  • For or against the creation of a chapter on Windows XP?

    • Against (50%, 5 Votes)
    • For (30%, 3 Votes)
    • Do not pronounce (20%, 2 Votes)

    Total Voters: 10

    Chargement ... Loading ...