WordPress/Mandigo/FAQ/How do I make sidebars disappear on a particular page
From onehertz
[edit] How do I make sidebars disappear on a particular page?
If you would like to have some pages displayed without some of the sidebar columns, you can EITHER use a custom page template, OR use a javascript snippet that will hide the column when the page loads.
[edit] Using Javascript
Add the following lines to your page in code view (not the rich text editor):
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#sidebar1').hide();
});
</script>
If it doesn’t hide the one you expected, the other sidebar is named "#sidebar2". And if you wanted to hide both sidebar on this page, replace "#sidebar1" with ".sidebars".
Please note however that this trick should not be applied to posts, as it will also hide the sidebars on pages such as the index or the archives on which this post is displayed. If you really want to use this trick in a post, put the javascript snippet after the "more" tag.
[edit] Using a page template
Creating a page template is actually pretty easy, and lets you apply a different layout to a set of pages:
- make a copy of page.php (the default page template) and name it something like "page-nosidebar.php"
- edit the newly created file and add the following lines at the very top of the file so that WordPress knows about the template:
<?php /* Template Name: Page with no sidebar */ ?>
- at the bottom of the file, remove the lines which include the sidebars you do not want to show up, i.e. either sidebar.php or sidebar2.php or both.
- If you want to hide only the first sidebar (it could be on the left or on the right of your content column, depending on the options you set in the theme options page), remove the "include (TEMPLATEPATH . '/sidebar.php')" line
- If you want to hide only the other sidebar, remove both the "include (TEMPLATEPATH . '/sidebar2.php')" line, AND the condition right above it
- If you want to hide both sidebars, you can delete the whole if block, leaving only the "get_footer()" call
For reference, here is what the default sidebars calls look like in Mandigo as of version 1.34:
<?php
// if we have at least one sidebar to display & if we chose to display sidebars in single post view
if (!get_option('mandigo_nosidebars') && get_option('mandigo_always_show_sidebars')) {
include (TEMPLATEPATH . '/sidebar.php');
// if this is a 3-column layout
if (get_option('mandigo_1024') && get_option('mandigo_3columns'))
include (TEMPLATEPATH . '/sidebar2.php');
}
get_footer();
?>
That's it!
Once this is done, you can assign the new template to new and existing pages from the Write Page section in the WordPress dashboard.
