Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Mar 13 '12 at 20:23
    
+1 See also: the Codex entry for custom Page templates. –  Chip Bennett Mar 13 '12 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. –  Chip Bennett Mar 13 '12 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 Mar 13 '12 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. –  Chip Bennett Mar 13 '12 at 20:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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