WordPress leaves a lot of room in terms of design flexibility, without losing its ‘shape’ thanks to the modularity of its templates. Think of these as the ‘bricks’ that are put together, as directed (in query strings) to create a wall (webpage) in a building (website).
That wasn’t so bad as far as analogies go…
For a WordPress theme developer, custom page templates are actually more important than any paint job with CSS. Why? The custom page templates can deviate from default WordPress page structure and contain special features, layout options, etc. Simply put, your WordPress theme gives as much autonomy to its users as directed in its templates.
In this post, I’ll walk you through the process of creating a custom page template in WordPress.
The Basics of creating a page template
Technically (and quite literally too), the process is as simple as creating a new file. Go to your theme folder, create a new code txt file and paste this opening block of PHP in it.
- <?php
- /*
- Template Name: Test-Run Custom Page
- */
- ?>
This step applies to the custom page template creation, regardless of theme: Whether it’s WordPress default, a third-party theme, or your own custom theme. Nonetheless, I would advise you to start with a child theme. Here’s a detailed tutorial on how to create a child theme in WordPress.
Once that’s done, the custom page template will appear in your page attributes menu (in WordPress admin’s “Edit Page” screen). To apply the page template, you simply have to select it and click ‘update’. The page’s live view will immediately change as per the code in this template file.
Here’s a basic custom page template, created from one of the WordPress default themes (Twenty Fourteen).
- <?php
- /**
- * Template Name: Test-Run Page
- */
- get_header(); ?>
- <?php
- if ( is_front_page() && twentyfourteen_has_featured_posts() )
- {
- get_template_part( 'featured-content' );
- }
- ?>
- <div id="primary" class="content-area">
- <div id="content" class="site-content" role="main">
- <h1>Hello There</h1>
- </div>
- <!-- #content -->
- </div>
- <!-- #primary -->
- </div>
- <!-- #main-content -->
- <?php
- get_sidebar();
- get_footer();
- ?>


Vignesh ManiPosted Jun 9, 2016, 5:19 AM
Good One.
Santhakumar MunuswamyPosted Jun 9, 2016, 12:28 AM
Thank you for nice share
Debasis SahaPosted Jun 7, 2016, 3:52 PM
Nice share..