Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

How to Create Custom WordPress Template Posts, Pages, Headers, Footers and Sidebars

September 6, 2013 4 Comments

How to create new WordPress templates for your theme including posts, pages, headers, footers and sidebars.

To change the WordPress home page

  • edit the index.php in the main theme
  •  if using a child theme, just copy and then edit the file in your child theme folder
  • alternatively you can create/edit front-page.php  – this will take priority over the index.php

To make a specific WordPress custom template page

  • create the page in WordPress front end via the editor
  • get the Page ID – which you can find whilst editing the page – look for the format in the url field “post.php?post=2092&action=edit” – here the ID is 2092
  • copy page.php and rename it page-2092.php
  • if using a child theme put the page-2092.php in the child theme folder
  • change the html/php to suit
  • if another template is used with a different name  – then copy that and rename it with the same initial name and append the number ‘templatename-2092.php‘

Instead of using the ID number you can also use the URL slug instead, so if you had a page /about-us you could use a template page-about-us.php

These principles also apply to category and tag templates.

To make global WordPress custom template pages

To build a custom page template and use it across any page you create from within WordPress dashboard, copy and edit the page.php template and say rename it to page-new.php, declare it as a template by adding this php declaration at the top of the file:

<?php
/*
Template Name:News Page
*/
?>

Then access it from within the visual editor and select the new template.

custom wordpress page templae

To make a custom template for a single WordPress post

– this is done quite differently and involves a couple of different ways to do it if you just want to make subtle template changes I recommend installing a plugin that allows you to use the same method as creating page templates. If your needs are more complex the other method is to create and register the custom post types and have them in a separate menu outside of the regular posts – this covers that way.

So the easier way is to install and activate  a Custom Template Plugin that allows the functionality – there are a couple of these, this one seems to be popular and updated recently.

Creating the Post Temple

The post template is taken from the single.php template.

  • locate the single.php and make a copy and call it something like single-newspost.php
  • open the copied template
  • make a php statement in the head of the file and name the template, in this case named “News Post”
<?php
/*
Single Post Template:News Post
*/
?>

single post template

– It will then be available from within WordPress dashboard in the Posts edit page in a widget called ‘Single Post Template’ and can be selected to use. Initially the widget is below the visual editor you can drag it to the right column so it appears in the same area as the Page Custom Template dropdown.

To make custom headers, footers and sidebars (2 ways)

Easier way

  • copy and rename header.php, footer.php or sidebar.php
    – e.g header-special.php
  • edit the new file
  • reference the new file from another template by appending the suffix name, like so:
get_header('special');

Slightly longer way

  • copy and rename header.php – e.g specialheader.php
  • in the custom page or new template, reference the specialheader.php by changing:
<?php get_header(); ?>

to

<?php include (TEMPLATEPATH . '/specialheader.php'); ?>

If you are using a child theme, you need to call ‘get_stylesheet_directory() .’

<?php include (get_stylesheet_directory() . '/specialheader.php');  ?>

Cats: Tech, Theming, WordPress Tags: custom, pages

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • Musi says evidence shows Apple conspired with music industry on App Store ban
  • Trump threatens Apple with 25% tariff to force iPhone manufacturing into US
  • I helped a lost dog’s AirTag ping its owner: An ode to replaceable batteries
  • Apple legend Jony Ive takes control of OpenAI’s design future
  • Epic goes to court to force Fortnite back on US iOS

RSS mac surfer

  • Tot is new text editor for Mac, iPhone, and iPad focused on constraints and ease of use
  • TiPbITS: Google Drive Sorting Can Hide New Documents
  • How to take a screenshot on a MacBook Pro
  • How To Create Simple Animation With Mac Keynote
  • Last Week on My Mac: Virus pandemics

Donate

Copyright © 2025· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2025 · gee on Genesis Framework · WordPress · Log in