How to Create a Custom Page Template for WordPress

0

Most WordPress themes should have a file that serves as the default page template that any page in a WordPress build will be assigned to by default — it should go by page.php. Sometimes, however, the default page template might not be conducive to the design and functionalities of all of your pages. You might need to create an extra (or even a few extra) custom page templates to make sure all your pages can serve their intended purposes.

To create a custom page template, you’ll ned to create a new file within your theme. Give the file a name that would indicate its purpose. Rather than start from scratch, the easiest way to create a new page template is to find the default page template and copy and paste that page into your new custom page file. Then you’re going to need to customize the information at the top of the file pertaining to the page’s name and description:

<?php
/*

* Template Name: INSERT PAGE NAME HERE
* Description: INSERT PAGE DESCRIPTION HERE
*/

// other page code

?>

The name you assign to “Template Name” is what will appear on your WordPress dashboard when assigning a template to a page. Now it’s time to add custom code to your new page. You can decide if you’d like to include a sidebar, a loop, or just completely customize the code with your own HTML. Don’t forget to add some extra style rules to your CSS to compensate for the changes in the page structure/content.

Source

You might also like More from author