This tutorial goes over how to create a WordPress page template and use a custom widget area in the sidebar.
In the last tutorial, we added a new widget area to our WordPress theme. In this tutorial, we will use that new widget area and display it on a custom WordPress page template.
How to create a new WordPress page template
Below are the steps from the video:
- Duplicate and save the
page.php
file in a new directory calledtemplates
- Save this new page as
contact.php
in thetemplate
directory - At the top of
contact.php
add the following markup to register the page template:* Template Name: Contact
- Go to your WordPress Dashboard and create a new page that uses the new Contact page template
- Duplicate
sidebar.php
and save it assidebar-contact.php
- In
sidebar-contact.php
change all instances ofsidebar-1
tocontact
- In the
contact.php
page template changeget_sidebard()
toget_sidebar('contact')
- Go to Appearance -> Widgets from the Dashboard and add a widget to your Contact widget area
- View the Contact page on the front-end and verify your widget area is working
Don’t forget to edit the comments sections in both the contact.php
page template and in the sidebar-contact.php
file.