Showing/Hiding sidebar based on page – almost there but need help!
-
Hey all. I’m setting up a site as more of a CMS with a blog page on the back end. The page links are running in a menu across the top, and for most pages I’ve managed to hide the sidebar(s) based on the page. I’m doing this with this bit of code in the header:
<?php if (is_page('blog') || is_single()){ ?> <style type="text/css"> #content { font-size:15px; float:left; width:590px; padding:0 0 0 1em; } </style> <?php } else { ?> <style type="text/css"> #sidebar { display:none; } </style> <?php } ?>
What that’s doing is hiding the side bar if the page is not a blog or single post page, and showing it if it is. Currently this is working on the “static” pages and the single post pages – but not on the main blog page.
Here’s where I’m running into trouble: I set the blog page up as “Blog”, and the slug is “blog”. However, when I do go to the blog page, the slug is the name of my current post: “sample-post”.
Is there a way to check for the main blog page? Thanks for your help!
- The topic ‘Showing/Hiding sidebar based on page – almost there but need help!’ is closed to new replies.