0

I am trying to find the feature to add a page template. I am adding an archive but when I go into pages->Add New-> I get no option in the sidebar to use the existing archives.php file I want to use. Can anyone help me out?

1 Answer 1

2

archives.php is a template file that WordPress will use by default (if it exists). If you want to create a custom page template you need to create a new template file in your theme. You can read all about it in the Codex, but I'll provide an example below. Put this at the top of your new file:

<?php
/*
Template Name: Your page template name goes here.
*/
?>

Then follow it with the custom code you need to display your data.

Then, when creating a new page that you would like to use the above template, you will see a drop-down list on the right that lists all the names of page templates you have in your theme.

9
  • I already have code similar to this in my style.css file. I created a theme from scratch and applied my CSS to it. i Created a custom archives.php file yet it doesn't display in the dashboard to allow me to select it as a template
    – NATHAN C
    Commented Mar 13, 2012 at 20:23
  • +1 See also: the Codex entry for custom Page templates. Commented Mar 13, 2012 at 20:24
  • "I already have code similar to this in my style.css file." - It's not what's in your style.css file that matters, but rather the phpDoc header in archives.php. Commented Mar 13, 2012 at 20:25
  • The above code does not go in your stylesheet, it HAS to go at the top of your custom page template. Archives.php is a file name that is reserved by WordPress. If you want to use that same file, simply rename page-archives.php and it should work.
    – cmegown
    Commented Mar 13, 2012 at 20:25
  • 2
    Actually, archives.php is not reserved; that would be archive.php. Though, I would still recommend using something like template-archives.php as your custom Page template file name. (I would not use page-archives.php, as page-{slug}.php is reserved by the Template Hierarchy. Commented Mar 13, 2012 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.