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 have a static homepage with a custom template I.E hompage.php the blog loop is set to a static page named blogg, it uses the index.php page as a template, there a collection of other pages using the index.php as the default template so i am reluctant to change it. is there anyway to stop the blogg page from using index.php and give the blog page it's own template page such as blogg-template.php? kind regards Chris

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Please consult the Template Hierarchy, and ensure that you are using the correct names for template files.

  • index.php should be left as the default fallback for all other template files
  • The site front page template file name is front-page.php. You need to rename your homepage.php as front-page.php
  • The blog posts index page template file name is home.php. WordPress will always and only ever use either home.php or index.php for the blog posts index (unless the blog posts index is set to display on the site front page, and front-page.php exists). No other template files will be used, regardless of what you name them, or whether or not you assign them as custom page templates to the page used to render the blog posts index.

Step-by-step:

  1. Create front-page.php as your custom front-page template
  2. Create home.php as your blog posts index page template
  3. Leave index.php alone
  4. Create two static pages, of any name; e.g. "Front Page" and "Blog"
  5. Go to Dashboard -> Settings -> Reading
  6. Set Front Page Displays to a static page
  7. Set Front page dropdown to "Front Page" static page created in step 4
  8. Set Posts page dropdown to "Blog" static page created in step 4
share|improve this answer
    
Thank you for the walk through, I didn't quite need it but it's nice to have. I am relatively proficient in php/html/js/css I had read the template hierarchy i was just curious to if there was a workaround. thanks for the time taken out of your day. Kind regards Chris –  vimes1984 Apr 15 '13 at 15:37

You need to refer to the Template Hierarchy to understand what you need to do. Specifically, you need the "Home Page Template" section.

To modify the blog page (aka "Page for Posts) (which is the "home" page, even if it's not set as your "front page"), you should use the home.php template. The blog will automatically use it. index.php is only used for your blog if home.php is not present in your theme's folder.

If you try to select a Custom Page Template on the page set to the "Page For Posts" setting on Settings > Reading, it will be ignored. You have to use home.php.

share|improve this answer
    
thank you just the answer i was looking for :D is there any way to stop it ignoring the custom page templates? –  vimes1984 Apr 15 '13 at 15:23
    
"is there any way to stop it ignoring the custom page templates?" - No, it is not possible. WordPress will always and only use home.php or index.php to render the blog posts index. You can use filters, such as template_redirect, but if wouldn't recommend trying such techniques until you've grokked the template hierarchy. –  Chip Bennett Apr 15 '13 at 15:28
    
Yup. Like @ChipBennett said, going about this any other way is a pain, but also doesn't make sense seeing that WordPress has a predefined way for handling this that has worked in the past and will work well into the future. There's nothing to fix because there's nothing broken :) –  mrwweb Apr 15 '13 at 15:37
    
tou-che @mrwweb I'll stop trying to be a smart A*SE and just deal with what works, I'm moving from a long time templating in modx and i think i have been spoilt... –  vimes1984 Apr 15 '13 at 15:43

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.