How To Create A Custom Page Template In WordPress

by · 135 comments

email

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(); ?>
 

The 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:

Add Page in WordPress Screenshot

and assign your new custom page template to it:
Assign page template in WordPress
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:

Selecting a static home page in the WordPress Reading Settings

Now your custom page will be the first thing visitors see when they come to your website!

Here’s a video walkthrough: Creating WordPress Page Templates.

Update: watch this video to see how to create a custom page template that is editable from the visual WordPress editor!

See my WordPress Powered Websites series for more WordPress articles, tips and tricks for small business websites!
 
 

If you enjoyed this article, get email updates (it's free).

See my disclosure about advertising and affiliate links

{ 127 comments… read them below or add one }

Doug C. August 28, 2010 at 12:48 pm

For some reason his site takes a long time to respond, even on my cable speed. This guy created a child theme based on Twenty Ten, which I decided to use for my client’s site. It’s a nice theme with tons more customizations than that new default theme.

Reply

Doug C. August 28, 2010 at 3:06 pm

A WP.org forum moderator is helping me figure all this out. He was kind enough to implement all this on his test site and give me access so I could check it out. Now I’m just trying to figure out all the different parts so I can make it work on my client’s site.

What a guy :)

Reply

Corey at Soda Pop Reviews November 12, 2010 at 1:19 pm

Thanks Don! I can’t believe I didn’t know the simple templates code in WP. I’m implementing this on my blog today. You rock!

–Corey

Reply

Gina January 4, 2011 at 8:58 am

Don,
Command prompt isn’t recognizing the code. What am I doing wrong?

Reply

Don Campbell February 10, 2011 at 8:24 am

Hi Gina, this needs to be done on your host where you have WordPress installed. Is that where you are trying to make the changes?

Reply

Mujahid February 10, 2011 at 8:18 am

I have checked all the thing and it’s not working.. :(

Reply

Don Campbell February 10, 2011 at 8:26 am

Hi Mujahid,
What isn’t working for you? Can you give me some details on what you are seeing?

Reply

Charlie February 18, 2011 at 11:02 am

Everything is working. Thank you for the good tips.

Reply

zoran draganov February 25, 2011 at 2:42 pm

Briliant man ! I was searching for post like this for 2 days. Finnaly I found the answer of me question. Thank you :)

Reply

pat mcclanahan February 28, 2011 at 6:58 am

Don – thank you!! I have hand crafted websites for year – just recently realized I needed a tool like WordPress…and your article was HUGE in getting me pointed in the right direction.

Reply

Mike Flynn February 28, 2011 at 12:26 pm

Hi Don, I followed your instructions, but I still end up with the comment box between the header and footer. Thank you for any help on this problem.

Reply

Ardeshir March 11, 2011 at 11:31 am

Thank You!
Nice tip and working great, WP 2.9.2

Reply

Charlie March 16, 2011 at 10:09 am

thank you for you help Don.
Your tips helped me to launch my own website

Reply

Endyst April 8, 2011 at 1:01 am

Good article! Thank you!

Reply

Fred April 22, 2011 at 4:43 am

Hi, I really just want to get rid of the Home Label but keep the side bar menu as-is. Is there any simple way of doing this?

Reply

diet to you April 30, 2011 at 3:45 am

thanx Don

Reply

Slate Blank May 13, 2011 at 1:47 am

Nice article. Thanks for the help.

Reply

Muhammad Ali June 9, 2011 at 5:55 am

this is is a nice tutorial ,i got the idea of making custom template.

Reply

cute programmer June 10, 2011 at 6:20 am

hello there! thanks for the tutorials, but i do have some questions. Is this still updated tutorials? because i follow all your instructions and it seems it doesnt work for me. even the template, it doesnt appear.

Reply

Don Campbell June 10, 2011 at 3:33 pm

@cute – Yes this is still current. What kind of problem are you having? When you say the template doesn’t appear, do you mean in the Page when you select the page template? Did you name it properly in the PHP?

Reply

Amita Shrestha June 16, 2011 at 8:19 pm

thanks for this tutorial. it is very useful.

Reply

Francisco June 29, 2011 at 10:24 am

This is exactly what I want to do–I want a Website, not a blog.

I was doing really good on your previous step to make the home page static, but when I got to this section I got lost.
“That’s where you will create your custom page template file”, I have no idea how to do that, I wish you would have showed us step-by-step. Thanks anyways.

I wish there was free website themes/templates that looked like a website not a blog.

Reply

Karen August 4, 2011 at 12:33 pm

Great post! I have a question – where can I get information on formatting the content of my new page? Right now the sidebar is still present, although empty. And the text I added is just plain text right now.

As you might be able to tell, I’m just dipping my toes in the waters of customizing a theme.

Thanks

Reply

Ken August 5, 2011 at 9:17 am

Hi, Don:
I created cover.page and try to edit it, it give me eroor message like this

Parse error: syntax error, unexpected T_STRING in /home/acuherb2/public_html/wp-content/themes/960_pixel/cover_page.php on line 2
how can I fix it thanks
Ken

Reply

Ken August 5, 2011 at 10:10 am

Hi, Don I solved the problem, but I have one more how can I add new side-menu related to my new page. thanks
ken

Reply

Clayton August 17, 2011 at 12:37 pm

Don,

I can’t for the life of me figure out this section, “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.”

I started using wordpress with Google Chrome and a Windows XP OS. Any ideas?

Reply

pat August 17, 2011 at 5:56 pm

Hey Clayton,

What part of the instructions seem to be giving you trouble? Do you have access to the server where your Wordpress is loaded? Have you loaded any themes, or are you just using the default theme?

Chrome and Windows XP are just fine…are you trying to run Worpress on your XP computer?

Have a great day
pat

Reply

Clayton August 18, 2011 at 11:24 am

Pat,

Thanks for the reply, I would assume I don’t have access to the server that I installed WP on, or I simply don’t know how to get to it. I’m running the theme Twenty Ten. Thanks.

Reply

Pat McClanahan August 22, 2011 at 8:18 am

Okay – if you do not have access to the server where you performed the install it a bit more difficult to actually make use of Wordpress.

I am curious then…how did you get Wordpress installed if you have no access to the server? Most web hosting companies allow some sort of access via ftp or ssh. I am thinking that if you were able to install Wordpress then there is some form of access that you can get to it.

You say you are using Windows XP – did you install Wordpress on your Windows XP computer?

Cheers
pat

You should contact your web hosting company and ask about access to use Wordpress.

Reply

Clayton August 22, 2011 at 11:51 am

Pat,

I think the base of the confusion is that I never actually installed wordpress. I signed up for an account and make any changes after logging in via wordpress.com.

Reply

pat August 22, 2011 at 3:13 pm

Ahhhh…that would explain the confusion….I guess I have never worked with an account on the wordpress.com website. You need to go to the wordpress.com website and login, from there you can get support about how to use their services. I am not sure if this tutorial applies the the wordpress.com site or not.

This is more for those who run wordpress on a server where they have more control that you do at wordpress.com (I think that is true).

Good luck,
pat

Reply

Don Campbell August 23, 2011 at 4:49 pm

Yes you’re correct Pat – this will only work with self-hosted WordPress, not WordPress.com sites. Thanks for answering Clayton’s question!

Reply

Pat McClanahan August 24, 2011 at 6:45 am

Well…its the least I can do. I found your article when I was first digging into Wordpress and it was a HUGE help. There were many others who helped along the way – so just tryin to pay back for the blessings so many shared with me.

BTW: I concur – great article.

Reply

kursat August 23, 2011 at 12:47 pm

After contacting my theme “live support” 20 times and getting unrelated help posts from them, I realised…your tutorial was all I needed.

Thanks a lot, just created the custom landing page for one of my sites.

The only difficult part is just uploading the contact to the folder each time, but all happy with the outcome.

I have one question, can we also get rid of the default header and footer and put custom ones there? may be you have a PHP code fo this?

thanks again

Kursat

Reply

Don Campbell August 23, 2011 at 4:50 pm

Hi kursat,
Yes, you can just leave out the get_header and get_footer functions in the code snippet above, then they won’t be included in your page template.

Reply

Michael September 15, 2011 at 12:29 pm

Don / Whomever –

Being fairly new at this, especially with this latest find. Could someone possibly guide me in the direction of adding an external stylesheet to (page-style.css, etc) to my newly created page template?

I’m sure it’s fairly obvious, but it seems my brain doesn’t have the capability to perform such a task.

Thanks!

Michael

Reply

Pat McClanahan September 16, 2011 at 6:30 am

Hey Michael,

In the WordPress Dashboard, select the Impact menu on the left side, then the Template Builder (if it doesn’t open when you select Impact).

You then select the template you desire to add the style sheet to using the Edit Template box in the upper left corner. Once you have selected a template then click the Show Template Options button. The very last option in the Template Options is the Template Custom CSS. Click on this and you can edit the css thats there….you can cut and paste anything you want.

When you are done click the Save Template button and you are good….

So – to actually answer your question – you can edit the existing Impact style sheet…but you don’t actually have an external sheet. I have always been able to do whatever I need in this style sheet.

Hope this helps…

Reply

angela September 24, 2011 at 7:18 pm

Hi Don-the-life-saver,

I have found my way to the cPanel file manager, wp-content, themes, BUT, there is no ‘default’. There is both twenty ten AND twenty eleven as possible themes. I have set to Twenty eleven and it is coming up OK, but am unsure where to place the new file I made (as instructed above). If I put it in the twenty eleven folder it doesn’t change my refreshed opening page, ie there is still the box, ‘leave a reply’. I don’t actually need a blog function at all and want to remove this box. Can you help please ? many thanks,

Reply

Pat McClanahan September 26, 2011 at 6:28 am

Hey Angela,

Which files are you trying to find a place for? I am not sure how to answer this one…but only because I am unsure of which files you are refering to.

Have a great day
pat

Reply

Angela September 27, 2011 at 4:19 pm

Hi Pat,

I am referring to the “leave a reply” comment box at the bottom of each page. I want to remove it completely but am not sure how this would be filed or where to look in the file manager page on cPanel to remove it.

Many thanks,
Angela

Reply

Don Campbell September 27, 2011 at 4:24 pm

Hi Angela,
Have you tried just turning off comments for the Page inside WordPress?

Reply

Angela September 27, 2011 at 8:01 pm

I have it sorted, thanks. Found my way to pages, quick edits, quick links, allow/disallow comments button. Really easy.

Thanks for the help
A

Reply

Don Campbell September 27, 2011 at 8:04 pm

Great – thanks for letting us know Angela. I’m glad you’ve got it working!

Reply

ino October 10, 2011 at 7:18 pm

Hi Mr. Don, I have a question here, I want to create my home page different from other page, I want my home page only show one single image at the center, and button call “enter site”, so when visitor click that button it redirect to my present home page. Thanks.

Reply

sed November 17, 2011 at 9:15 pm

i too want to do this …..i just want a page with enter in the middle then it will enter the site the way it is right now ..i like my theme its cool just want a page that says enter then you get to the main site i have made the template and done a background pattern ,now i will put the hyperlink saying enter (BUT WERE DO I DIRECT THE TARGET , SO THAT IT SHOWS WORDPRESS NORMALY WITHOUT MY CUSTOM PAGE)) URGENT

Reply

s1 October 15, 2011 at 12:08 pm

I have a very stupid question – I started off with your first article and I got my Custom Page and the Blog page at the bottom. That worked.
Then I read your second article and created my own Custom Template and put my content in coverpage. php. That works too!
But where is the blog? I can’t get to the blog page with my Custom Template. Does the blog page even under a directory that I can refer to? How can I keep the blog at the bottom of my coverpage.php?
Lastly, does server-side includes still work inside coverpage.php. I can’t seem to be able to get it working.

Reply

Sun October 19, 2011 at 1:36 am

@s1

Just cannot see how you struggle with so simple thing.
So.. you can hyper link your first cover page image to your blog like this

Copy the code to your new coverpage.php just make sure you did change the names to fit your domain and image.
Using the code above your image will be centered in the middle of your cover page with no showing blue border around clickable image. And visitors will have access to your entire blog from here on.

Reply

Sun October 19, 2011 at 1:41 am

ups…
code is gone

Once again here :
‘[
]‘

Remove ‘[ at the beginning and at the end ]‘ in case it shows up here

Also! In the code you see that your image goes into /images/ folder, but your can place it on your domain root, then it will look like http://www.yourdomain.com/image

Reply

harry December 1, 2011 at 7:47 am

Don, thanks for showing this trick. I created a php file and moved it into the content folder I could see it in my template window. But when I changed the name of page I couldn’t find this php file in the window. Also, can any php files I move into the content folder be shown in the template window? Where is the impact menu Pat mentioned in the dashboard? Thanks.

Reply

Pat McClanahan December 2, 2011 at 8:54 am

Mornin Harry – Which page did you change the name on? If there are references to the page name in your php code, make sure that you change those to match to page name.

Re: the impact menu – make sure you have the Impact plugin installed and activated. It will appear in the list of plugins on the left side of the dashboard.

Hope that helps
pat

Reply

harry December 2, 2011 at 11:07 am

Pat, thank you. I’ve figured out my page issue :-) . Could you please tell me the full name of Impact plugin, because I didn’t see “impact” when I searched in plugin? Many thanks. harry

Reply

Pat McClanahan December 2, 2011 at 3:03 pm

Harry – glad you got your problem solved.

The plugin is named – Impact Page Builder – http://www.impactpagebuilder.com – you can find more information there about how to download the plugin and get it installed.

Fell free to let me know if you need some additional assistance.

pat

Reply

harry December 2, 2011 at 6:29 pm

Pat, awesome tool! Thank you~~ I am curious how we can make a webpage alive, just like a calendar or google Ad. I know we can get it from mysql/php, but it still requires labor work. I want something completely automated and fresh everyday. Any idea :-) ? Best, harry

Reply

Pat McClanahan December 2, 2011 at 6:53 pm

Harry – the best way to find stuff is to use Google – I use search terms like “Wordpress Calendars”, or “Wordpress Calendar Plugin”…..you can also find articles about the top 10 Wordpress plugins….you gotta just go looking for what you want and find the plugin that meets your needs. Read the reviews, try different ones…its a bit of work – but well worth the effort.

Good luck
pat

Reply

url December 8, 2011 at 2:45 am

Thank you for sharing nice article..

Reply

Ed January 8, 2012 at 6:33 pm

Hi Don,
Maybe I have the wrong program, but all I want is a normal website. The blog feature is fine but what I want also are the menu items ie: Home, Blog, etc.
Under each item though, I would want to place pictures of my progress etc. with a description beneath each photo. Is this possible to do with wordpress or should I look for a different sort of program to accomplish this?

Thanks In Advance
Ed

Reply

Tammy January 10, 2012 at 10:39 am

Hi Don,
I was wondering if you could use this same process for creating a template in a post. Or would it only work for on a page in wordpress?

Reply

Shimon January 20, 2012 at 4:56 am

Hi Don, I try to create a Custom Page in WordPress using suggestions in your article. I created successfuly custom page template file, called “private_page.php”, and added the suggested code to it.
Now I want to create a usual (not Cover) Page Based on my new Custom Page Template. I created a new page called “Private Page”.
How can I connect the new “Private Page” with custom page template file
“private_page.php”, which code to use?
Second question: How can I bring this page to be unvisible in Title of other site pages?
Thanks in advance,
Shimon

Reply

Shimon January 20, 2012 at 5:56 am

Dear Don,
after some attempts I successed to create the Page Based Custom Page Template. Your explanation in article was Great, thanks.
Now remain the second question: How can I bring this page to be unvisible in Title of other site pages?
Thanks once more,
Shimon

Reply

Don Campbell January 20, 2012 at 9:54 am

Great Shimon – I’m glad you’ve got it working.

What do you mean “unvisible in the Tile of other site pages?”

If you want to remove any page from the menu, you can do that easily with the WordPress menu builder. Here’s a video that shows you how.

Reply

bob hukiont January 29, 2012 at 3:48 pm

Thankyou for this your blog it is very information fufillingand this post is amazing

Reply

Leave a Comment

{ 8 trackbacks }

Previous post:

Next post: