First, you need to open a text editor  add the blank file add this line of code at the top:

<?php /* Template Name: Custom Page Template */ ?>

Editing Your Custom Page Template

Your custom page template can add any HTML, template tags, or PHP code in this file.  The easiest way to get started with your custom page is by copying the existing page template provided by your theme.

Open the page.php file in a plain text editor like Notepad, and copy all its content except the header part.

Your custom page template would now looks like this:

<?php /* Template Name: Custom Page Template */ ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
    <main id="main" class="sitemain ">
        <?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( ‘bottom' ); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Save your custom page template file using FTP and you can remove the sidebar, add custom PHP code, add any other HTML you want.

Related Article

0 thoughts on “How to Create a Custom Page in WordPress”

Leave a Reply