WordPress.org

Ready to get started?Download WordPress

Forums

Create pages without sidebar ... (8 posts)

  1. pfigg
    Member
    Posted 7 years ago #

    I want to create a few pages with the main site page as the parent. No problem with this ...

    - is it possible to create these secondary pages minus, the sidebar? I need the full area within my standard K2 theme in order to design pages with large sized technical diagrams.

    Thanks.

    -ptfigg.

  2. pizdin_dim
    Member
    Posted 7 years ago #

    This is one way of doing it: in your "page.php" file, change the line at the bottom that says:

    <?php get_sidebar(); ?>

    with this:

    <?php if ($wp_query->post->post_parent == 0): ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    You should also change the column class at the top that says:

    <div id="content" class="narrowcolumn">

    with this:

    <?php if ($wp_query->post->post_parent == 0): ?>
    <div id="content" class="narrowcolumn">
    <?php else: ?>
    <div id="content" class="widecolumn">
    <?php endif; ?>

    Because you're using a fixed-width layout, you may have a little more "fun" than you originally anticipated, getting it to work precisely.

  3. moshu
    Member
    Posted 7 years ago #

    Isn't about 100 times simpler to have a separate Page template?

  4. pfigg
    Member
    Posted 7 years ago #

    Thanks guys,

    moshu, can you elaborate?

    -ptfigg.

  5. moshu
    Member
    Posted 7 years ago #

    I don't need to. The Codex is doing a pretty good job: http://codex.wordpress.org/Pages#Page_Templates

  6. pizdin_dim
    Member
    Posted 7 years ago #

    "Isn't about 100 times simpler to have a separate Page template?"

    No, you're way off with your estimate. It's only a little bit simpler. And even then, it's debatable. With a separate page template, you still have to put in the changes I suggested. Then, on top of that every "sub-page" you create, you have to specify that new tamplate. What I suggested does that automatically for every sub-page.

  7. moshu
    Member
    Posted 7 years ago #

    Then, on top of that every "sub-page" you create, you have to specify that new tamplate.
    You should read the documentation and learn WP before making untrue statements like this...

    And with a Page template you don't need to mess with conditional tags, which is always easier for non-techie users.

  8. pizdin_dim
    Member
    Posted 7 years ago #

    "You should read the documentation and learn WP before making untrue statements like this."

    I have. And you shouldn't assume that I haven't. Perhaps you misunderstood me? Let me give you an example of how I understand it:

    1. You create a page template called "parentpage.php", which WP recognises as a template because you have "<?php /* template name: parentpage */ ?>" in the header.

    2. You create another page template called "childpage.php", which WP recognises as a template because you have "<?php /* template name: childpage */ ?>"` in the header.

    The two template files are only different in that "parentpage.php" has a sidebar and "childpage.php" does not.

    Every time you create a top-level page (no parent), you specify "parentpage" as the template. Every time you create a sub-page (parent exists), you specify "childpage" as the template.

    That's one way to get no sidebar on secondary pages. Another way is to just modify the existing "page.php" (if your theme has it) as I already suggested.

    If you read the original post again, I think you'll find what I suggested is actually less error prone because the template itself determines if it's going to show the sidebar. The author doesn't have to remember to select a "childpage" template. The downside to my approach is that you can't specify that you want a sidebar on some of your secondary (sub) pages.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.