Buy All 48 Premium WordPress Themes for $54.99

Exclude Sidebar from Specific Pages

Our Premium Themes come with built-in Sidebar with options to display or hide it on All pages and posts:

  1. Login to your Admin Panel
  2. Navigate to Left Menu -> Appearance -> Customize -> ‘General’ Section
  3. Check/Uncheck ‘Display Sidebar in Pages’ and ‘Display Sidebar in Posts’ checkboxes
  4. Save Changes

In some cases you may want to display the Sidebar on All pages and hide it only for certain pages. Here is a guide how it can be done:

Make Sure Sidebar is Displayed on All Pages

First, you need to display the Sidebar on all pages:

  1. Login to your Admin Panel
  2. Navigate to Left Menu -> Appearance -> Customize -> ‘General’ Section
  3. Check the ‘Display Sidebar in Pages’ checkbox
  4. Save Changes

Get Page/Post IDs on which you want to hide the Sidebar

The second step is to get a list of page IDs on which you want to hide the Sidebar.

You can get a Page ID by opening the corresponding page in Admin Panel for edit, then copy the ‘post’ value from the URL, i.e.

Add Functionality to Skip Displaying of Sidebar for Page IDs

The last step is to add a small code change which actually skips displaying of Sidebar for specific page IDs:

Login to your Admin Panel

Navigate to Left Menu -> Appearance -> Theme Editor

Open page.php (Single Page) file

Replace the below code:

$showSidebarForPages = tishonator_read_customizer_option('tishonator_general_showsidebar_forpages', 1) == 1;

with:

$showSidebarForPages = tishonator_read_customizer_option('tishonator_general_showsidebar_forpages', 1) == 1 && !in_array( get_the_ID(), array('1676', '1677', '1678') );

where 1676, 1677, 1678 are posts IDs from previous step.

Save Changes

About the Author

Tihomir Ivanov is a WordPress and Salesforce Commerce Cloud (SFCC) developer, founder of tishonator.com, a fan of Linux and Open Source, Minimalism (in Design and Life), Sci-fi, Fantasy, Classic and History books :)

Leave a Reply