How to Create a Custom WordPress Page Template

How to Create a Custom WordPress Page Template

Child theme's folder

Then, upload the template file you’ve just created to this folder. This template should now be available on your website.

To confirm this, navigate to your WordPress admin area and create a new page (or open an existing one). In the Settings panel, locate the Template section and click on it to view your options:

 

 

WordPress template section on the block editor

You should see your new template in the list. However, if you set this as the template and click on Preview, you’ll get a blank page.

This is because we haven’t added anything to the file yet. We’ll show you how to customize it in the next step.

Step 3: Customize Your Template File

First, you’ll need to copy the existing page template of your theme. To do this, connect to your site via FTP and navigate to your current theme folder. Then, look for a file called page.php and open it in a text editor.

Next, you’ll need to copy the following code within the page.php file:

The default page.php file

When you’re done, open your custom page template file and paste that code just below the following line:

<?php /* Template Name: CustomPage */ ?>

Your template file should now look something like this:

The custom page.php file

You can now edit your custom page template file. For instance, if you want to remove the footer from the template, you can delete the following line:

<?php get_footer(); ?>

You can also add custom PHP code to customize the template to your liking further. When you’re done, save your changes.

Now, if you return to the post or page where you’ve applied the template and click to preview it, you should be able to see your new changes.

 

2. Create a Page Template With a Page Builder Plugin

Don’t worry if you lack knowledge in coding. There is an easier way to create your own templates, and it involves using a page-building tool.

Fortunately, several WordPress page builders enable you to build custom designs. This section will be looking at two popular options – Elementor vs Beaver Builder.

Building a C

Pages: 1 2 3 4


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *