How to create custom template in WordPress



Some specific pages of website required different types of template or layouts. In WordPress we have the ability to create/change the template of page in admin. So today I am showing you how to create custom template page in WordPress.

By default your WordPress theme uses page.php as a default template for every page which makes the page look a certain way. You can create your custom template which has different structure and look and use this template file for particular page.

Following are the steps to create custom template page:

1. Go to your current theme folder in wp-content/themes/
2. Create a file custom-page.php (you can give it any name)
3. Now give a name to your template file like below:

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

?>

4. Now go to admin->pages and create a new page.
5. In template drop-down select custom template page.

Template Section
Template Section

6. Currently the page will be empty so in template page add following lines or as per your requirement:

<?php get_header(); ?>

<div id="main-content" class="main-content">

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">

			<?php
				// Start the Loop.
				while ( have_posts() ) : the_post();

					the_content();

				endwhile;
			?>

		</div><!-- #content -->
	</div><!-- #primary -->
	<?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->

<?php get_footer(); ?>

This way you can create your own custom template in WordPress. You can also prefer our video tutorial below. I hope this will help you.