0

Creating WordPress Custom Page Templates

wp-custom-page-template

In WordPress you start off with 2 default types of posts you have the standard posts and you also have pages.

For these types of posts WordPress will use different PHP files to display the content, the standard posts will use the single.php file and the pages will use the page.php file.

But the problem with this is that you can only use one file for your pages so you can’t have different page layouts or styles. This is why WordPress created the ability to create custom page templates, which allows developers to create as many different page templates as they want.

Create A Custom Page Template

To create a custom page template all you have to do is add a new blank php file to your theme directory and save this as custom_page_template.php. Within this new file all you have to do is add comments to the top of the file.

Adding this to the top will automatically add this file to a drop down when adding a new page, from the drop down you will see the default template (page.php) and Custom Page Template.

If you select the new page to use the Custom Page Template then this will override the page.php and your page will use your custom page template.

Examples Of Custom Page Template

Some of the common examples of custom page templates are contact pages, full width pages and archive pages.

Create A Contact Page Template

The contact page will make it easy for your website visitors to send an email to the admin email address of your WordPress blog.

Below is an example to use for a contact us page, you can copy and paste this code into a new PHP file to easily add contact pages to your WordPress theme.

[php]

 

Leave a reply