How to create a page without a sidebar in WordPress?

Sidebar is useful on most of the pages of a WordPress site – you can add recent posts or categories there. However on pages like Privacy Policy it seems unnecessary. I use a simple and nice WordPress theme Twenty Thirteen, but it lacks a page template without a sidebar. Here I will show how to create such a template in a few very easy steps. Note that the idea is not mine – it is a compilation from other sources.

Since I want to install theme updates without extra work, I actually use a child theme. And in the child’s folder I have only style.css:

wp 002

Using FileZilla I’ve copied page.php from twentythirteen folder to my computer, renamed it as no-sidebar-page.php and replaced the file header with:

<?php
/*
Template Name: No-Sidebar Page Template
*/
get_header();
?>

Then removed this line from the code in the file:

<?php get_sidebar(); ?>

Then I’ve copied no-sidebar-page.php back to mytwentythirteenchild folder:

wp 003

Then in WordPress admin panel I went to the editor and added this to the very end of style.css (I could have edited style.css right in FileZilla):


.page-template-no-sidebar-page-php .entry-header,
.page-template-no-sidebar-page-php .entry-content,
.page-template-no-sidebar-page-php .entry-summary,
.page-template-no-sidebar-page-php .entry-meta
{
  padding-right: 0;
}

Now, every time I create or edit a page – I have an option of selecting either a default template with a sidebar or a new No-Sidebar template:

wp 004

4 thoughts on “How to create a page without a sidebar in WordPress?

  1. Thank you so much for posting this article. This helped me a lot. I was so much strugging to get on/off of the sidebars for specific pages. Most of the times I avoid using plugins. And get it done from scratch even I am not the coding type.
    Any way your post has helped me a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *