Articles > Development
Printer Friendly Version
Views: 3198

Wordpress - Hide Sidebar on some pages

Last Updated: 1/17/15

I needed to hide the sidebar on a single page of my Wordpress website, but I wanted a solution that would work on future pages if needed.

My google searching revealed some concepts on how to do this, but most solutions involved editing the page.php code to with some static code that lists the page name.

other solutions:
<?php if ( is_page('my-portfolio') ) { get_sidebar(); } ?> 

my solution:
edit your page.php

change this:
<?php get_sidebar(); ?>

to this:
<?php if ( has_tag('nosidebar') == false ) { get_sidebar(); } ?>


Then install the Wordpress plugin that lets you have tags on pages.

WordPress › Tag Pages « WordPress Plugins
https://wordpress.org/plugins/tag-pages/

then add the tag, "nosidebar" to any page and the sidebar will be hidden on that page.

note:
You edit your page.php and upload it back to your site via FTP
or you can use the Appearance > editor instead.





Keywords: none