Viewing 5 replies - 1 through 5 (of 5 total)
  • Don’t be confused by what an archive is–it is just a generated display of your posts at that moment. You don’t do anything to create the archive, that’s an automatic thing WordPress does for you. Usually, archives are date, category, tag, or author, based.

    Access to archives is typically presented via links in a sidebar under an Archive (date based), Category, or Tag Cloud, headings. Widgets, or Template Tags such as wp_get_archives(), wp_list_categories(), wp_tag_cloud(), and wp_list_authors(), are the constructs used to present links to users to visit your various archives. The process of placing code in your Theme’s Templates is explained in Stepping Into Templates and Stepping Into Template Tags.

    Once a user clicks on a Category link in the sidebar, the display of those posts can be controlled by a Category Template. Other Templates, such as Author Templates, and Tag Templates, are available if you set them up. These Templates can be coded via Template Tags such as the_title(), the_content(), or the_excerpt(), to display just a post title, the full content of the post, or just an excerpt of the post.

    Also, it is important to understand the Template Hierarchy, as that is how WordPress determines what Template to use to render the posts for reading by your readers.

    If a user visits a Category archive, then clicks on a given post title in that Category archive, the display of that single post is again presented by another Template, and again, the Template Hierarchy determines what Template displays that single post. Finally, that single post Template can be coded to display just the title, the full post content, or an excerpt.

    Thread Starter thsoto

    (@thsoto)

    I understand that. I want a link on my homepage that says “Archives”.

    When clicked, I want them to get a new page that has either displays the archives using wp_get_archive(‘type=postbypost’) or wp_get_archive(‘type=monthly’). But it has to be a new page, not in a sidebar. Creating an Archive Index page like the Codex says does not apply to Version 2.8.6.

    Upload the archives.php in your theme directory (wp-content/themes/themename/). Then from the Admin Panel, Pages > Add new

    Give your new archives Page a suitable title like Archive Index. Leave the Page content blank.
    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!

    In 2.8.6, there is not a Page Templates box in the sidebar. Therefore, I can’t create the Archive Index page.

    Try this.

    Switch to the WordPress Default theme.

    In the wp-content/themes/default folder save this code in a file called archives-page.php

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    /*
    Template Name: Archive Page
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content" class="widecolumn">
    
    <h2>Yearly Archives:</h2>
    <ul>
    <?php wp_get_archives('type=postbypost'); ?>
    </ul>
    
    </div>
    
    <?php get_footer(); ?>

    Then, create a page called Archive Page and when writing that page, select “Archive Page” from the Template pulldown.

    Okay switch to the WordPR

    Thread Starter thsoto

    (@thsoto)

    Thanks!

    I was leaving out this

    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */

    /*
    Template Name: Archive Page
    */
    ?>

    That’s why I wasn’t seeing the dropdown menu in the sidebar.

    Thanks MichaelH your write up helped understand a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to create an archives page’ is closed to new replies.