The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

WordPress Ignores the index.php & uses the page.php instead

  • # December 3, 2009 at 10:34 am


    I’m currently learning to create themes in WP but I’m a little confused. I created my HTML/CSS page and then I started converting it into a WP theme using an empty theme from starkers which contains a lot of pre-made themes like page.php, archives.php, comments.php etc, but I noticed that WP was ignoring the index.php template which should contain the main content and that was driving me crazy so I decided to start from scratch and then I started deleting all templates except the four basic ones (header.php, index.php, sidebar.php and footer.php) and as soon as I deleted them my theme worked just as it should, then I put all the templates back into the theme’s folder and again the page wasn’t behaving as it should, so I started deleting the extra templates one by one to find the one causing the problem and I found that the one causing the problem was the page.php, I deleted only this template and the theme now works just fine. It looks like it was showing the page.php instead of the index.php which doesn’t have a sidebar. The problem is now solved but I would like to know how this happen because now I won’t be able to use the page.php if I would need to. May be I changed the settings in the Admin area to use a different template? If yes, where is this option?

    Any idea why or what was causing the problem?


    # December 4, 2009 at 1:57 am

    Well, what is actually happening is that the themeing system is working just like it should.

    Quick WP theme explanation:

    index.php is the LAST RESORT for any page/post/category, etc. If you go to the "Cool" category page (that has the id of 6), the theme will look for themes in this order:


    It will go down this list until it finds a template, and then it will use that template.

    More detailed information: WordPress Hierarchy

    # March 2, 2010 at 10:42 am

    Thanks a lot! For your reply.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed