Forums

[resolved] hide sidebar on pages? (4 posts)

  1. darren hibbs
    Member
    Posted 2 months ago #

    How do hide the sidebar on some of the pages? or hide some widgets on the pages? is it possible? as i just want the my blog page to show the categories and archive widgets.
    Regards Darren

  2. allyanders
    Member
    Posted 2 months ago #

    If you want to get rid of the sidebar on some pages you'll need to make another page type.

    I have one I call "blank" and it doesn't have a sidebar. Just the header, content, and then the footer.

    I copied the default "page" template in wordpress, gave it a new name (blank.php) and then added this to the top of the file

    <?php
    /*
    Template Name: blank
    */
    ?>

    Look in there for something about sidebar. In my file it said:
    <?php get_sidebar(); ?>

    Delete that line.

    Save it. Upload it back to your theme.

    Then when you go into the Wordpress admin to Pages > edit select your page. Look for Page Template. There should be a dropdown. You want to select blank. Save and view your page.

    Hope that helps.

  3. jessn
    Member
    Posted 2 months ago #

    Or you can use conditional comments in the sidebar>

    <?php if (is_page('about-me')) { ?>
    widgets code
    <? } elseif (is_page('8')) { ?>
    widgets code
    <? } elseif (is_page('blog-page')) { ?>
    
    <? } else { ?>
    
    <? } ?>

    Is your blog page an actual page, or the default blog page? If it's default then you'll want to declare your pages first, and let the } else { part define what shows on the blog page. If blog is a page then just fill in it's ID or slug in one of the elseif's

  4. darren hibbs
    Member
    Posted 2 months ago #

    thank you both for your comments but i think i would try the conditional comments. Thats a great help. Thank you for your help.

Reply

You must log in to post.

About this Topic