WordPress – all pages link to the index.php file

[NEW AT WORDPRESS]

I’m creating my own wordpress theme with own css etc etc. I’ve managed to get everything good in the index.php file, and I’m trying to make the other pages as well now.

Read More

When I make the home.php, blog.php, about.php and contact.php file (in my theme folder) they don’t link to it. I’m following the “WordPress 3: Creating and Editing Custom Themes with Chris Coyier” on Lynda.com and the example shows that whenever you make a file with the same name as your page, it takes that directly (which works at his tutorial).

Anyone that could know what is going on?

Example:
I got a file blog.php in my theme folder, and when I go to www.mydomain.com/blog the loaded file is the index.php file, instead of the blog.php file

Related posts

Leave a Reply

2 comments

  1. There are two ways you can get this working using custom page templates.

    1. Create a template for one specific page using the page slug or ID. In this case, change the name of the php files like this to match the name of the page you created in the UI: page-home.php, page-blog.php, page-about.php and page-contact.php

    2. Much more flexible is to create a custom template that can be used on ANY page. Just add the template name to the top of the php file like so (inside the php block):

      /*
      Template Name: My Home Page Template
      */

    Then edit the pages and select your custom template from the template dropdown menu (on the right hand side I think, if its visible).

    Reference this page for more info: https://developer.wordpress.org/themes/template-files-section/page-template-files/

  2. Found the solution to my (silly) problem.

    Creating a page in your theme directory & adding the template comment at the top of your php file isn’t enough. You need to go to the admin panel->pages->YOUR PAGE-> and check out the page attributes. There you can link the page to a certain template: http://d.pr/i/a0m0