Custom Page Templates

Used for defining the layout of one or more Page.

Custom Page Templates generally define the overall structure of the Pages in your website. The default Page Template is located at wp-content/themes/mytheme/page.php. We often want certain pages to appear differently than others, so lets see how easy it is to create a new Custom Page Template.

Step 1:First lets create our new Custom Page Template. Create a new file named home-page-template.php (wp-content/themes/mytheme/page-templates/home-page-template.php). At the beginning of our file we have to tell WordPress that this is a Template, so the first few lines must look like this:

Step 2:Now lets define the content and structure of our new Template. Refer to page.php in your themes directory if you want to copy some of that code. You may add whatever you like, but here is a quick example:

Step 3: We are done creating a Custom Page Template! The last thing to do is set one (or more) of our Page’s templates to be our new Home Page Template (you would probably only have one home page, but keep in mind that you can apply this new template to as many Pages as you like). Navigate to your wp-admin page and go to Pages–>All Pages. Select a Page (or create a new one if you like) and click the Template dropdown under the Page Attributes section.

  • img
  • img
  • img
  • img

Specialized Page Templates

Used for defining the layout of a single Page.

Similar to the Custom Page Templates, Specialized Page Templates allow us to define a new layout for a Page. The difference is that Specialized Page Templates define the layout of a single Page, and cannot be used by any other Page. Lets see what this might look like.

Step 1: Inside of our themes directory, create a file named page-home.php (wp-content/themes/mytheme/page-home.php). This is where our Specialized Page Template will be defined. Note that we cannot place this file in a sub-directory, or if using a Child Theme in it’s Parent Theme’s directory.

Step 2:Lets add some content to our new Specialized Page Template.

Step 3: Now, to tie things together, navigate to your wp-admin page. Go to Pages –> Add New. For the Page title, enter ‘Home’. A Specialized Page Template filename must match the format page-{slug}.php, where {slug} in our case is ‘home’. The title of our new Page must match this {slug} for things to work (with the exception of the first letters capitalization).

Signup to Get a Free Logo

If you purchase our web design service you get a premium Logo Free