Support » Themes and Templates » Creating a Page to utilise Archives.php

  • Resolved YellowSwordfish


    Maybe a bug; maybe reported already. 1.5.1 based on Kubrick theme.

    I created a new page and used the Archives page template. Everything worked just fine. Then I decided to edit the title. After that, page template reverts to default and it is no longer in the templates dropdown. Actually if you use both ‘Links’ and ‘Archives’ the dropdown disappears. The only way I could link the template back in was to manually enter it in the database (wp_postmeta table) and all is well again. It’s a nice feature to stop using the same template twice but this way causes confusion.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Same problem here.

    In my drop down list, there’s only:

    So no other template is detected.

    I put a bug up on Mosquito about this but its not fixed yet. I believe anyway.

    Well, I don’t see what the bug is. The archives.php template is meant to be used once: when creating your “archives page”. The template has no loop and, usually, it contains only something like this:
    <h2>Old Posts by Month:</h2>
    <?php wp_get_archives('type=monthly'); ?>

    <h2>Old Posts by Category:</h2>
    <?php wp_list_cats('optioncount=1'); ?>

    Why would you use it for anything else than your Archives? The Codex says quite clearly:
    archives.php – ignores Page content and instead displays a list of Archives by Month and Archives by Subject (by Category).
    Keywords: “ignores Page content”!
    So, no, you cannot use it for your links Page, your need another template for that links.php – in which you’ll put the call for the lnks, like get_links_list or something simiar.

    Other than that you can create a million Page templates, just have the proper heading.

    @dextro, if in your theme you have only the “default” page template then nothing else will show up in the dropdown.

    Moshu: archives.php and so on are all in the theme directory.

    So I don’t get it why they don’t show up.

    It’s the same with the default template. They don’t show up in the template list. I’m using version 1.5.1.

    does archive.php contain:

    <?php /*
    Template Name: Archives

    or something similar? It’s the only way it will show as a template.

    Then I decided to edit the title – can you clarify this – when you say you edited the title, where specifically did you edit the title?

    Can you write to your htaccess? Pages tend to have issues with certain hosts and permissions.

    Try this, and I may be stating the obvious, but just go through it again for clarity:

    1) ensure your archives.php is correct and that the top part of the file contains the above template requirement
    2) set your htaccess to 777
    3) create a new page
    4) can you see the archives.php file in the template selection box?
    5) if no, duplicate the file, rename the template name within the PHP file to someting else like Test, and repeat the process. Does the template display?

    Of course the template shoudl display regardless of whether you enter text, but I’m just speculating here.

    edit: not sure if it’s any help, but here’s my archives.php, you can test it out?

    <?php /*
    Template Name: Archives

    <?php include "header.php"; ?>

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

    <br />
    <h2>Archives by Category</h2><br />
    <?php wp_list_cats(); ?>
    <br />

    <?php include "footer.php"; ?>

    Addtionally, ensure that there are no additional white spaces above and below the file. It may just be sods law and one of those random events.

    Ok, The comment on top was missing.

    Thx a lot for this great explanation.

    The point of my original post was quite simple. First time into write pages the dropdown contains both Links and Archives. Once you have specified one of these templates, it disappears from the list in future. Which is fine and helpful. But I wanted to edit the title of the Archives templated page. So I opened it for edit. After changing the title it lost the Archives template link in the database. It really should have retained it.

    Why did I edit the title? Because I wanted it to show up in my Page listing on the sidebar – which I think is legitimate. So – this is a user friendly feature (i.e., not being able to use the template twice) with this one drawback.

    YellowSwordFish I don’t understand why you’re disgruntled.

    What you’ve just said is that you modified the template file and then you lost that template. This makes logical sense, as the archives defaults to archives.php, and if it’s not there it will use index.php

    Just to clarify that if you specify a template for a page it shouldn’t disappear from the list – I use one template for several unique pages and all the template file appear. If this is a new addition to WP then I think it’s a bad choice, unless it eliminates only the core requirements (archives.php, links etc).

    It makes more sense if you DUPLICATE the existing archives.php file and then modify that. I’m not surprised you lost your link because you modified a file being used. It wouldn’t retain it in this instance.

    Perhaps I’m not understanding it correctlt, but from what I can surmise, WP is working correctly and this is not a bug

    First off who said I was disgruntled? Secondly, if you read the post again I said NOTHING about modifying a template file. I said I edited the PAGE. The Codex tells me I can create an Archives file by having a template and then creating a PAGE that points to it. It works just fine. Read the post again to see what I did next.

    I’m not disgruntled. I’m actually very happy and I love the way WP works and integrates. But there are some small bugs here and there and this is one of them. It’s not crucial or life-threatening but if I find one, I point it out. But it IS a bug caused by being overhelpful and cautious.

    I created a new page and used the Archives page template. Everything worked just fine. Then I decided to edit the title.

    Sorry but you mention the page at the start, and then you mention the template there after, it’s not clear to me from your block of writing. Edit the title of what?

    That aside, I still can’t grasp what you define a bug and why it is a bug. As I said, I don’t know if this is a 1.5.1+ feature – I still use 1.5 myself. Are you saying this has changed since previous versions, and has this been verified as a bug?

    Sorry YellowSwordFish I’m probably being dense, it’s still morning for me and I still don’t understand. Can someone else confirm this as a bug?

    In “Page Template” dropdown menu, do you still see “Default Template?”

    Oh dear! OK –

    1 – follow the Codex article above. Using Kubrick and when you first set WP up, there are 3 page templates in the Write Page drop down. They are Default, Archives and Links.

    2 – If you create a page for Archives the Archives template gets removed from the drop down.

    3 – Same thing happens for Links.

    4 – Once you have created a page using Archives and Links templates, the drop down no longer shows as all that is left available is Default. I assume that this is trying to be helpful – to stop you creating multiple pages to either Archives or Links templates.

    5 – But say you want to edit the title of the Archives page (as I did) which is reflected in the default Kubrick sidebar under ‘Pages’.

    6 – Go to Manage Pages – choose the Archives page you created at step 2 and press edit.

    7 – There is now no template drop down (as you would expect). But…

    8 – After you edit the title and re-save, the originally saved Archives Template that the page is associated with is NOT re-saved into the database. When your browser shows the page it will use the default NOT the archives template.

    Yes – it’s a bug. A small not very significant and not very important bug but it can catch a user out. As it happens I understand bugs like this due to being a programmer for 20 odd years and I had no problem hacking it back into the database. But most people will just be confused.

    I owe you an apology. I understand why you were confused now and it looks like the bug was mine. My default Archives template did not have the:
    Template Name: Archives
    construct at the top. Thanks to TechWench on another question I understand all now. So – sorry for the confusion etc…

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Creating a Page to utilise Archives.php’ is closed to new replies.