Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Creating custom page templates in rtPanel child theme

Dinesh Jain edited this page Jan 17, 2016 · 1 revision

WordPress is no more a blogging platform, rather its been used as CMS widely. You need to have multiple pages with different layouts like landing page, portfolio page etc; and for this we need to develop custom page templates.

What is a template file?

Before moving across the implementation, We would like to tell you what actually are the template files in Wordpress. A Wordpress page is comprised of number of pieces united together. These pieces have been created for every significant section on a Wordpress page. We call every single instance of these pieces, as a template. For instance, we have the header.php and_ footer.php_ as the template files for header and footer respectively. So, we knew what a template file is.

Keep in mind that further in this post, wherever we talk about the template files, do keep the header.php and footer.php files in your mind.

What is a page template?

Now, these template files are however united in a particular manner within yet another single page template file (Template withing a template) like the index.php template files unite the header.php, footer.php and the sidebar.php template files. By default, this single page template file hierarchy starts with the custom applied page template file, then the page.php and the index.php at the last. The complete template hierarchy can be seen here. Similar to the default page template files available (index.php or page.php), we can create our own custom template files as well.

Why do we need to create a page template?

Presence of various rtPanel hooks is already an added advantage to us. But sometimes, there are several customizations to be done on a single page. In such cases, where we require a lot of customization using the hooks or we feel that the hooks are not going to do the job for us, we rather prefer creating a separate custom page template for it.

How to create the custom page template?

In the previous post, I had already explained about creating the custom page template in our child theme. The custom template must start with an information header, followed by uniting the header.php, footer.php and the sidebar.php files, as the requirement might be. The custom template code must be added as:

/**
 * Template Name: Home Page
 *
 * @package rtPanel
 *
 * @since rtPanel 2.0
 */

//adding the header.php template file to this page template
get_header(); 

//adds up the sidebar.php template file to this page template (if needed)
get_sidebar(); 

//your custom loops and markup lies here

//adds up the footer.php template file to this page template
get_footer();

Now all you need to do after this is make sure that your chosen page has been applied this template and displays the content as you wanted it to. Stay tuned as we are coming up with some more posts on rtPanel child theme development.

Cheers!

Clone this wiki locally