WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] suppress sidebar & header outside blog? (5 posts)

  1. storyfirst
    Member
    Posted 7 years ago #

    I'm new to WordPress, so please be kind.

    Also: I did search here, and elsewhere and I read everything that even vaguely touched on what I need. And I'm still stuck.

    I'm using a variation on the Kubrick theme that I got off the wp/themes site (two sidebars right).

    I need to have Pages that are without distraction --just the text and the comment form, a simplified header, and a link to the front page.

    I tried to do this by commenting out the 'get sidebar' command on page.php, but no luck. I'm pretty proficient at html but I'm just learning php. I realize there must be some kind of conditional statement (show sidebar/header only on the blog pages), but (1) how to write it and (2) where to put it -- I'm lost.

    As I said I did extensive searching, but if I somehow missed a thread that resolves this kind of issue, please point me in that direction. Otherwise any help would be greatly appreciated.

  2. Marcel Brinkkemper
    Member
    Posted 7 years ago #

    storyfirst, Did you use html comment tags <!-- --> ?
    They don't work in php. /* */ are comments in php.
    Try <?php /* get_sidebar(); */ ?> or delete the statement altogether.

    At the top of the file add:

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

    and save it as page_no_sidebar.php

    This page will now show up in your templates.
    Don't remove the get_header command from your template.

  3. storyfirst
    Member
    Posted 7 years ago #

    macbrink--

    Thank you so much for that quick reply. I was using the php way of commenting out, but it didn't work until I put it inside the sidebar statement as you showed in your example.

    So the sidebar is gone from those pages... but one unforeseen result is that the main column is still only as wide as it was. I'm thinking maybe css would be the way to specific a different page width for these non-sidebar pages?

    In html I would take the quick and dirty solution of putting some additional css at the top of the template to redine margins, but I haven't seen that done with php.

    Any thoughts? And thanks again, I do appreciate your help.

  4. Marcel Brinkkemper
    Member
    Posted 7 years ago #

    often a quick and dirty solution turns out to be slow and dirty.

    In your stylesheet add two classes:
    .narrowcolumn {width: XXXpx}
    and
    .widecolumn {width:YYYpx}

    change the XXX and YYY to the width you want your page to be with or without sidebar respectvely.
    yui can remove width formats from the original id.

    in your templates page.php and page_no_sidebar add these classes to the div of your content e.g.:
    <div id="content" class="narrowcolumn">
    and
    <div id="content" class="widecolumn">

    change the id="content" part to the id that is used in your template

  5. storyfirst
    Member
    Posted 7 years ago #

    Thank you, macbrink. That was exactly what I needed to know. All resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic