Adding Custom page in your theme
A custom page template is a file located in your theme directory. With it, you can change the layout of a page or show different content to the standard page template (e.g. page.php).
When you create and publish a page in WordPress, the file page.php is used for this.
page.php in this case is the template used by default.
To create a custom page you have two options. you can either modify the default page template or you can create one of your own.
You could, for example, use custom page templates for a certain section of your website and use the default template for the rest. You can build and deploy as many different templates as you like, so once you understand them, it really opens up a lot of options to customize your WordPress site to meet the needs of your website.
1) In your code editor, create a new file in the directory of the theme you are currently using.
Call it ‘page_contact.php’.
2) At the top of the file, insert the following code:
3) Copy the following code for page content
<pre class="wp-block-syntaxhighlighter-code"> &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;h1 class="page-title"&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;?php the_title(); ?&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;/h1&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;!-- Page Title --&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;?php // TO SHOW THE PAGE CONTENTS while ( have_posts() ) : the_post(); ?&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;!--Because the_content() works only inside a WP Loop --&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;div class="page-content"&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;?php the_content(); ?&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;!-- Page Content --&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;!-- .entry-content-page --&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;?php endwhile; //resetting the page loop wp_reset_query(); //resetting the page query ?&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; </pre>
4) Login to WordPress and edit the page you would like to use to try your new pageTemplate or create a new page and use your page template.
5) Under ‘Page Attributes’ (usually found on the right-hand side of the editor), select ‘Contact Template’ from the ‘Template’ drop-down.
6) Update/Publish your page.