How to create a WordPress page template with custom widget area

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:

  1. Duplicate and save the page.php file in a new directory called templates
  2. Save this new page as contact.php in the template directory
  3. At the top of contact.php add the following markup to register the page template: * Template Name: Contact
  4. Go to your WordPress Dashboard and create a new page that uses the new Contact page template
  5. Duplicate sidebar.php and save it as sidebar-contact.php
  6. In sidebar-contact.php change all instances of sidebar-1 to contact
  7. In the contact.php page template change get_sidebard() to get_sidebar('contact')
  8. Go to Appearance -> Widgets from the Dashboard and add a widget to your Contact widget area
  9. 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.