WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Template Hierarchy for page-archives.php? (6 posts)

  1. greenpeas
    Member
    Posted 6 years ago #

    Is there any Template Hierarchy structure for the archive page?

    I have a category page set up here: http://fbcwaynesboro.org/archives/category/sermons
    and would like to have a slightly customized archive page for the individual posts, within this category.

    Thanks!

  2. Joni
    Member
    Posted 6 years ago #

    You mean on the category archives page? Sure, that's easy. You can just create a new category template for whatever categories you want.

    For example, if your sermons category's ID is 8, then you just create a category page template called category-8.php. Put this commented code at the top so WP recognizes it as a custom Page template:

    <?php
    /*
    Template Name: Sermons
    */
  3. Kafkaesqui

    Posted 6 years ago #

    As joni mentioned, you can create a category template for a specific category. See here for more:

    http://codex.wordpress.org/Category_Templates

    Note that a template for a category and one used as a Page template should be managed separately. You can do as joni describes above to have WordPress recognize say category-8.php as a Page template as well, but when assigned as a Page template it will not behave as you may expect (that is, displaying posts from category 8).

  4. greenpeas
    Member
    Posted 6 years ago #

    Thanks Joni and Kaf, I think that's what I have now. http://fbcwaynesboro.org/archives/category/sermons loads 1-archives.php category page, which over-rides the archive.php.
    The question I had... was when you click on the individual post, (I guess that would be a single post, or perhaps a single archive posts) it defaults back to the archive.php, and loses my defined dynamic sidebar, which I set in the category-1.php.
    Will I need to set up a conditional tag in the archive file to load this dynamic sidebar for category 1 entries? Or, is there a "hierarchy" that covers the single posts (or would this be considered a single archive post?).

  5. moshu
    Member
    Posted 6 years ago #

    You need to re-read the Template_Hierarchy article.
    a) archive1.php - is not a recognizable template file for your monthly or category archives/listing
    b) for different category archives you need category-XX.php files, where XX is the cat ID#
    c) single posts are displayed by single.php template file (or, if missing, whatever comes next according to Template_Hierarchy)
    d) Different single layout: http://guff.szub.net/2005/07/21/post-templates-by-category/
    (a plugin)

  6. greenpeas
    Member
    Posted 6 years ago #

    I found a great idea on Lorelle's page which works very well. I tried using Kaf's plugin; but had problems getting it to work properly.

    btw, the template hierarchy article is really very helpful!

Topic Closed

This topic has been closed to new replies.

About this Topic