• Hello, I am looking for the specific code on how to hide the sidebars on specific pages.

    So for example, if I have a page entitled ‘About Me’ and it’s page id is ’27’ what specific code would I use so that on that specific page, and only that specific page, the sidebars no longer show.

    Please do not link me to codex, it is not of use to me in this situation, it does not show me how all of the things I’d like to do come together. I will learn nothing from it, I am asking for specific code because I learn by direct example. If someone is willing to do this, thank you.

    Examples I’ve seen of doing this would be things such as editing page.php by adding;

    <?php if (!is_page(’Page Title’)) : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    That does not work. it seems like it specifically CALLS for the sidebar, as in, it wants it active. I do not, what do I do to turn it off. What specifically is the code.

    I am being adamant about it and ‘drilling’ it in because people keep responding to me with codex links, that again, are not of use when they are not in any context.

    Thank you for your time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • To minimize dynamic page load times, the smartest thing to do is reduce code, not add code. I have had the most success making page templates, where I have eliminated the sidebar when it was unnecessary.

    In case you or someone else doesn’t already know how to make a page template: In your theme, duplicate page.php; rename it pageTitle.php (where pageTitle is whatever you want it to be); and open the file in an editor such as Dreamweaver or your preferred code editor.

    Add directly above <?php get_header(); ?>:
    <?php
    /*
    Template Name: pageTitle
    */
    ?>

    Then locate and delete the following to eliminate the sidebar:
    <?php get_sidebar(); ?>

    I hope that resolves your issue!

    This code.

    <?php if (!is_page(’Page Title’)) : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    Explained:

    <?php if (!is_page('SOMEPAGENAME')) : // If it is not this page, ! denotes NOT the value that follows, so in this case, the if the page is not "SOMEPAGENAME" ?>
    <?php get_sidebar(); // So if it's not the page above, then show the sidebar ?>
    <?php endif; // Just the end of the IF statement, nothing special ?>

    You can check if it is the page with..

    is_page

    or if it’s not the page with..

    !is_page

    If you need further explanations, just ask..

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to hide sidebars on specific pages’ is closed to new replies.