Skip to content

How do you make a custom page template in wordpress?

custom page

The concept of themes is one of the most essential selling features of WordPress. A single theme contributes a lot to the website’s aesthetic and functionality. On the other hand, some websites use distinct designs on different pages.

Several WordPress themes, unfortunately, prevent users from changing the look and functionality of a separate page in the hierarchy. Users can include bespoke requirements such as a right/left sidebar on a certain page, additional call-to-action features, or a customised header for a specific landing page using a WordPress custom page template. Let’s take a closer look at how the WordPress custom page template displays various types of material.

Custom page template in wordpress

A custom WordPress page template can be useful for a variety of things. Here are a few suggestions:

  • Display the most recent posts in each category.
  • Google Maps or any script can be embedded.
  • All authors are listed in alphabetical order.
  • Images that have recently been uploaded For the portfolio, a custom design page was created.
  • Page of Contact

A template file named page.php is responsible for the appearance of all pages and articles published on a WordPress website. Basic HTML, CSS, and PHP expertise are required to create or change a custom page template in WordPress.

Simply copy and paste the following code into any text editor:

The above piece of code informs WordPress that PageWithoutSidebar is a template file. You are free to choose whatever name you wish. This file should now be saved as PageWithoutSidebar.php. You can rename the file to whatever you want. However, don’t forget to keep the.php extension.

Now we’ll put our newly constructed template file to the test.

Go to your hosting control panel and log in. I’m using Cloudways — the fastest managed WordPress hosting – in this example. AWS, DigitalOcean, GCP, Linode, and Vultr are among the providers that Cloudways supports for WordPress applications. Go to the /wp-content/themes directory. Upload the PageWithoutSidebar.php file to your current theme’s folder.

Go to Pages > Add New in the WordPress Admin Panel. On the right side, you can see the new custom page template.Create a new page with the PageWithoutSidebar template. Publish it after you’re finished.Go to the newly generated page and open it. Because there are no design elements in the template yet, it displays a blank page like the one below.This demonstrates that the WordPress custom page template has been successfully deployed, allowing you to design a custom responsive WordPress theme.

It’s now time to add a few lines of code to the page to display the content.

In this demonstration, I’ll show you how to change the default Twenty Sixteen page template.

The page.php file in the /wp-contents/themes/YOUR THEME/ folder creates the default appearance of the pages. Copy this code from page.php.

Just below this piece of code, paste this code into PageWithoutSidebar.php.

Save it!

Your complete PageWithoutSidebar.php file will look like below.

Return to your original page and refresh it. Everything should work the same as it does on the default WordPress Twenty Sixteen theme.

Now it’s time to personalise it. As you can see, there is a right-hand sidebar. I’m simply going to remove it from this page. All other pages will use the Twenty Sixteen theme’s default design.

PageWithoutSidebar.php is the file to open. Remove the following lines from the file as you scroll down to the end:

This is the code that makes the sidebar appear on the page. Save the file after removing the line. The sidebar is no longer visible when you open the page’s URL.

The sidebar has been successfully deleted from this page, as you can see. The text alignment, on the other hand, isn’t very excellent. On the right side, there is a vacant space. The solution is to justify the text and stretch it to span the entire screen.

Return to PageWithoutSidebar.php and look for:


All you have to do now is change “content-area” to “site-content-fullwidth.” When you refresh the page, the material expands to its full width.Still perplexed as to why I built a custom page template when the page.php file could have been easily edited? It’s self-evident that if the page.php file is changed, all of the website’s pages will reflect the changes. The custom page template in WordPress is useful for applying a customised appearance to specific pages. In WordPress, you can also create a custom user role to provide different capabilities to users.