Support » Fixing WordPress » Take sidebar off of one page only

  • I would like to take the side bar off of my gallery pages (/gallery/landscapes; /gallery/insects; /gallery/fungi etc.) to showcase my photos better.

    I have perused the forums and have found what I believe to be viable answers to this question however one problem remains.

    I do not have the <?php get_sidebar(); ?> code in any of my PHP files for the theme “Photographic”.

    All the answers I’ve found require using/editing/moving this. Any suggestions as to what I should do?

    Thank you in advance.

    http://upcavage.com

Viewing 13 replies - 1 through 13 (of 13 total)
  • the sidebar is called from footer.php;

    first step;
    replace:
    <?php get_sidebar(); ?>
    with:
    <?php if( !is_page('gallery') ) get_sidebar(); ?>

    second step;
    you might need to adapt the css, based on .page-id-33

    Thank you! One more question, I’m trying to do this on all of my gallery pages…’landscapes’ ‘reptiles’ etc. Repeating this code with a different page call is not working. How do I do this?

    http://codex.wordpress.org/Function_Reference/is_page

    you can add multiple page IDs or slugs or names into the is_page() conditional tag

    Okay…I figured it out, but now my background color on the sidebar-less pages has reverted back to the original theme color. Any suggestions?

    This is what I did:

    <?php if( !is_page(‘landscapes’) if( !is_page(‘fungi’)if( !is_page(‘birdanimals’)if( !is_page(‘culture’) if( !is_page(‘insects’)if( !is_page(‘plantflowers’)if( !is_page(‘reptiles’) ) get_sidebar(); ?>

    I simplified the code like your said but the background color is still off…and my slideshow has disappeared on the homepage…

    you have somehow broken some code so the execution stops where you edited the conditional sidebar stuff.

    please post the full code of footer.php;

    and while you are customizing your site, switch DEBUG on to get useful error messages: http://codex.wordpress.org/Debugging_in_WordPress

    </section>
    
    <?php if( !is_page(array('landscapes','reptiles',' 'plantflowers','culture','birdanimals','fungi','insects') ) get_sidebar(); ?>
    
          <hr />
    
    	  </div>
    
    		<footer>
          <!-- feel free to remove the credit below, but we'd love it if you would leave it in. -->
    			<p>
    				© <?php echo date("Y") ?> <?php bloginfo('name'); ?> | Powered by <a href="http://wordpress.org/">WordPress</a><?php if (is_home()) { ?> | Theme by <a href="http://www.stinkyinkshop.co.uk/themes/">Stinkyink</a><?php } ?><br />
    				<a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>	and <a href="<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
    			</p>
    		</footer>
    		<?php wp_footer(); ?>
    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-39249380-1']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    
    </script>
    
    	</body>
    </html>

    there is an unclosed bracket in the second line; should be:

    <?php if( !is_page(array('landscapes','reptiles',' 'plantflowers','culture','birdanimals','fungi','insects') ) ) get_sidebar(); ?>

    I haven’t checked any further…

    It’s fixed! Thank you for your help alchymyth. There was a space and an extra ‘ between reptiles and plantflowers.

    I don’t know if I should open a new thread for this question, but I am trying to extend the content through where the sidebar was on all of my photo pages. i.e. I want each row to have three photos as opposed to two. I have played around a bit with this but haven’t had any luck.

    http://upcavage.com/gallery/landscapes

    you might be able to do something from within functions.php of the theme;

    there is this section which adds a body_class if the sidebar is active:

    // hack to add a class to the body tag ifw
    function photographic_has_sidebar($classes) {
    	// add 'class-name' to the $classes array
    	$classes[] = 'has_sidebar';
    	// return the $classes array
    	return $classes;
    }
    
    if (is_active_sidebar('right_sidebar')) {
      add_filter('body_class','photographic_has_sidebar');
    }

    try and change the second-last line to:

    if (is_active_sidebar('right_sidebar') && !is_page(array('landscapes','reptiles','plantflowers','culture','birdanimals','fungi','insects') ) {

    (untested as I don’t have the theme installed)

    Unfortunately it’s not working, it’s giving me a parse error on line 27 in the functions.php. I will start a new thread. Thank you for your help!

    my mistake, this time I forgot one closing bracket – corrected:

    if (is_active_sidebar('right_sidebar') && !is_page(array('landscapes','reptiles','plantflowers','culture','birdanimals','fungi','insects')) ) {

    Still giving me a parse error. Thank you for trying though!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Take sidebar off of one page only’ is closed to new replies.