Do you want to create a custom page in WordPress? You can see that many WordPress sites have different layouts for different pages. A custom page allows you to have different layouts when viewed from regular pages in WordPress. In this article, we will show you how to create a custom page in WordPress.

What is a Custom Page in WordPress
By default WordPress allows you to create posts and pages. Your WordPress theme controls the appearance of your pages by naming the template file page.php.

This template file affects all the single pages you create in WordPress. However, not all pages are the same. A small change in their layout and appearance can make them unique and more useful.

Creating custom page templates in WordPress requires a basic understanding of HTML, CSS, and PHP.

Creating a Custom Page in WordPress

First you need to open a plain text editor like Notepad on your computer. Add this line of code in the blank field:

<?php /* Template Name: custompage_pt */ ?> <?php get_header(); ?> <div id="primary" class="container">     <main id="main" class="site-main" role="main">         <?php         // Start the loop.         while ( have_posts() ) : the_post();               // Include the page content template.             get_template_part( 'template-parts/content', 'page' );               // If comments are open or we have at least one comment, load up the comment template.             if ( comments_open() || get_comments_number() ) {                 comments_template();             }               // End of the loop.         endwhile;         ?>       </main><!-- .site-main -->       <?php get_sidebar( 'content-bottom' ); ?>   </div><!-- .content-area -->   <?php get_sidebar(); ?> <?php get_footer(); ?>

You can save the file with any name, just make sure it ends with the .php extension.

For this next step, you’ll got to hook up with your website using an FTP client.

Once connected, attend your current theme or child theme folder. you’ll find it in /wp-content/themes/ directory. Next, upload your custom page template file to your theme.

Now you would like to login to your WordPress admin area to make a replacement page or edit an existing one.

On the page editing screen, scroll right down to ‘Page Attributes’ section, and you’ll find a template sink menu. Clicking thereon will allow you to pick the template you only created and publish it

You can now visit the page you created using custom page template. it’ll now look exactly like your other pages in WordPress..

Categorized in: