Showing posts with label Archives. Show all posts
Showing posts with label Archives. Show all posts

Sunday, April 26, 2009

Show all posts in a category in the Archives page

Dump this code in the Archives template before the loop.
<?php
global $wp_query;
  query_posts(
    array_merge(
    array('showposts' => -1),
    array('offset'=>1),
    $wp_query->query
  )
);
?>

Thursday, January 1, 2009

How to create WordPress Archives page

To create an archives page for WordPress, you can use the Page Template feature. Here are the steps:



  1. Create an empty file—using your favourite text editor— in your theme folder, and name it archives.php, or whatever you like.

  2. Append these codes inside archives.php.
    <?php 
    /* Template Name: Archives */
    ?>
    <?php get_header(); ?>
    <div id="archives">

    <h2>Archives by Month:</h2>
    <ul> <?php wp_get_archives('type=monthly'); ?> </ul>

    <h2>Archives by Subject:</h2>
    <ul> <?php wp_list_cats(); ?> </ul>

    </div>

    <?php get_footer(); ?>


  3. Create a new page in WordPress, and name it Archives.
    Create new page

  4. Change the Template Attributes for Archives page, which is usually located at the right hand side of the Edit Page page,  to Archives (The name will depends on the template name).
    Change the page Template Attribute.

  5. Click on the Update Page button to save.


Now, you already have an archives page by month and by subject/category. By the way, you could also have the archives page to display some or all posts title, as discussed in this article.