Building a WordPress Template

Why? A good reason to build a WordPress template is to utilize a custom appliaction on a wordpress site that is pretty easy to do if you are a programmer and prefer to be organic and purist without using plugins which can be risly for a few reasons. They can conflict with other plugins causing major headaches in trying to identify the problem as well as security issues that were not addressed when the plugin was built. So here are the basic steps to building a custom template.

Step 1: Core code of your template.
The template must reside in the directory that contains your child theme (if you are not using a child theme you should be lest ye loose some work on a theme update). For this example lets just call our template “Text Outside of Page”

File name: text_outside_of_page.php
File Content must have the following:

Author: Jim Kerr
Template Name: Text Outside of Page

$recent = new WP_Query(“pagename=text-outside-of-page”);
while($recent->have_posts()) : $recent->the_post();

echo “<p>Here is your text outside of page.</p>”;


Step Two: Build Page
Add a new page for this example we will call the Page Text Outside of Page

Step Three: Select your Text Outside of Page Template
To do this in the Page Editor on the right column select you template under Page Attributes > Template here you should see your Text Outside of Page in the drop down menu if you did Step one correctly. This comes from the Template Name in the top of your code in the template.

That’s all there is to it!


Hits: 18