Tutorials

How To Create A Custom WordPress Page Template

Pinterest LinkedIn Tumblr

Neglecting the site for some time and running out of ambition to post new content, here is another more popular post from the past. Originally posted on July 9, 2007, this post is getting the most views on the site and should still be relevant today. Sorry, but I will probably not answer your theme-specific questions so I suggest you read the comments section or if you have any specific question, write down in comments.

There may be times when you want to create a blog page or that looks different than a normal page. Or Perhaps you want to use WordPress to run your entire website but want the main page of your domain to look completely different than a typical blog. This is an easy way to customize WordPress that can be very easily accomplished by creating a custom WordPress page Template.

Steps To Create a WordPress Page Template

The first step is to create your desired page in HTML, I use an HTML editor since I am somewhat geek impaired and can’t actually write any code. In this case, we are not going to add content to this page from within the dashboard so add all your meta tags for SEO. It will need a title, description, keywords, basically everything a regular static HTML page would need. After you create your new page you need to create a new WordPress page template. This can be done either in a text editor and FTP uploaded to your site or since it is a small simple file you can create it directly in your hosting account’s control panel.

To create the new page template paste your HTML code into a text editor like Notepad, then paste the following PHP code directly above it like this:

Copy just 2 lines of code above the <html> tag and paste it into your new template and change New Template Name to a name of your choosing. Save the new page template as a .php file. Something like front.php, and upload it to your hosting account in the template folder of your current WordPress theme. Don’t call your new template page.php! There is already one called that. In fact look in the themes directory to see what files exist to not create a duplicate.

You can look at your current page.php template to get clues as to what you may want to include in your custom page template like the header and footer or possibly the sidebar. But if you include everything in the custom page template as the regular page template why bother?

The directory to place the new page template in is /wp-content/themes/default. Where default is the currently active theme.

Since you are placing this new WordPress page template into a specific themes folder it will only be available when that specific theme is active. If you change themes you will need to place a copy of it into the currently active theme.

To create a new page template within your hosting accounts control panel. Browse to your blogs main directory, wp-content, themes, then click on your currently active theme. Create a new PHP file, call it whatever you wish, like above front.php, paste your HTML code and then the PHP code directly above it and save.

Creating Your New Custom Page

Login to your WordPress Dashboard, click Add Page. Since we didn’t specify in the custom page template to get the content, or any other information for that matter, all we need to do here is create a new page and specify the page template to use.

Type a title in the title box, then look over to the right and click the Page Template drop down box, choose your new WordPress page template and click publish.

Using A Custom Static Front Page

If you want to use your new custom page for a static front page you will first need to create another regular page as a URL as your blogs Posts Page . Create a new page and give it the title blog, or anything you want. Again don’t bother writing any content, on the right side type the same name as the title in the Post Slug box and click publish.

To specify using a static front page, click Settings then the Reading subpanel. Choose the Static Page option, specify your new custom page as the front page and the newly created blog page as the Posts Page and click Update Options.

Note! You do not need a custom page template for a static front page. You can create a page with all the content on it, you want for the front page, and then a blank page for the post page. Then choose the static front page option as above.

Now your blog will show your new custom page as the front page. But what about your blog? Where did it go? If you followed my directions and used the blog as the Posts Page AND if you have the postname in your permalink structure the URL should be YourBlogsURL.com/blog , so if your blog is in a directory called blog then the URL will be www.site.com/blog/blog. Having a blog/blog URL isn’t all that cool huh? Well, this is intended for use on a website ran entirely on WordPress without a static HTML front page. But you can use a different name in the title and Post Slug when you create the new Posts Page.

For more technical information about this subject :WordPress Pages

If you are using a static front page and your theme has a navigation bar you may want to tweak the navigation bar from showing the Home link and then the static front page link. Here is another guide to Customize WordPress Header Navigation Bar.

Editorial Staff

Editorial Staff at WPArena is a team of WordPress experts led by Jazib Zaman. Page maintained by Jazib Zaman.

Write A Comment

Pin It