WordPress Advanced – Create Custom Page Templates
WordPress is an extremely versatile platform and can be used for a variety of websites. If any custom development is required you may need to create a custom page template.
Creating a custom page template will allow you to add blocks & custom script to specific pages.
Create Custom Page Templates
1. Firstly you will need to create a new PHP page template file. Ensure this file is named relevantly (i.e ‘about-us.php’) – this will make it easier to find in future.
2. upload to:
public_html/wp_content/themes/YOUR_THEME/page_templates
3. For WordPress to recognise this file you will need to include the following code in your new template:
<?php
/*
Template Name: Full Width Page
*/
?php>
In your “Page Template” drop down you will be able to see your new template. At this point the template will be blank if applied.
4. Including the following code in your custom template will call the wordpress header & footer.
<!--?php get_header(); ?-->
<!--?php get_footer(); ?-->
5. Including the following code will display information entered in to the WordPress admin for the specific page.
<!--?php if (have_posts()) : while (have_posts()) : the_post(); ?-->
<!--?php the_title(); ?-->
<!--?php the_content(); ?-->
<!--?php endwhile; endif; ?-->
6. Including the following code will display the wordpress sidebar & sidebar widgets.
<!--?php get_sidebar(); ?-->
Conor Tomkins
Senior PHP Developer
Working with PHP applications since the age of 17. I have a wide range of knowledge on most PHP open source platforms. I must admit, my favorites are Magento & Wordpress!