This is a follow-on from my article called: How To Make WordPress Look Like a Website, where we walked through changing which page shows up as the home page for your WordPress website. The idea was to make it look more like a web site rather than a blog.
We changed the front page, but were left with the Page title and Sidebar still. So what if we want to completely customize our home page?
WordPress Page Templates are the answer
WordPress provides a clever way to do this called Custom Page Templates. To create a WordPress Page Template, you’ll need to use your text editor. Go to the directory on your server where you installed WordPress, and then navigate to the directory of your theme. Usually that looks something like this: “
/wp-content/themes/default” where “
default” is your theme name.
That’s where you will create your custom page template file. Create a file called “
cover_page.php” and add the following code to it:
<?php /* Template Name: Cover Page */ ?> <?php get_header(); ?> Here's my cover page! <?php get_footer(); ?>
Template Name: Cover Page tells WordPress that this will be a custom page template, where
Cover Page is the name that will show up in the drop down selector when you create your page.
The other lines in this file simply include the header and footer of your blog. You can add any HTML that you want to display on your page in the middle.
That’s it – now you have a custom page template!
Creating a Page Based on Your Custom Page Template
Now all you need to do is create a new Page in WordPress:
and assign your new custom page template to it:
Now you will have a completely blank home page, with only the header and footer for your site. You can add ANY code you want to this page and customize it until your heart is content.
One caveat though – you’ll find that any content you put into the “page” you created in the WordPress editor will not show up here. Since you are overriding the page with a custom page template, you’ll need to add your content to the
cover_page.php file that you created in order for it to show up.
Once you have the page looking the way you want it, go into Settings -> Reading in your WordPress Admin panel and set the “Front page displays” settings to look like this:
Now, your custom page will be the first thing visitors see when they come to your website!