WordPress.org

Ready to get started?Download WordPress

Forums

How to remove sidebar on 1 page, and keep it on the others? (32 posts)

  1. AlxDesign
    Member
    Posted 6 years ago #

    I've been trying to figure it out a bit, but instead of spending more time doing that, I could just ask here.

    http://www.alxdesigns.com/dev/wp/home

    I'd like to have the sidebar on all pages, except on the Gallery page. How do I deactivate it?

    Thanks / Alx

  2. AlxDesign
    Member
    Posted 6 years ago #

    Nevermind. I remade the flash itself, instead.

  3. Len
    Member
    Posted 6 years ago #

    Hi AlxDesign. Unfortunately I didn't see your post earlier. I see you have taken an alternate route but I'll respond anyway in case you change your mind or for the benefit of others stumbling across this thread.

    You could accomplish this in a couple of different ways.

    1. Through the use of conditional tags OR
    2. By constructing a new template. Also read this. Scroll down about half way to Creating Your Own Page Templates.

    Option #1 - Your Gallery page will be using the page.php template file so look in there for the sidebar call. <?php get_sidebar(); ?> and adjust it to look like this ...

    <?php if (is_page('x')) : ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    ... where "x" is the ID number of that page.

    Option #2 - Build a new template and assign your Gallery page to use it instead of page.php This is not as hard as it sounds. You can make it a complete duplicate of page.php with the exception of the sidebar call of course.

    Be advised that whichever option you, or anyone else chooses, you may want to make further changes. Why? Because now that the sidebar is gone from a certain page you will have a rather strange looking empty space in its place. You would probably want to widen the content area of that page so that it takes up that extra space. You can take a look at the default Kubrick theme to see how this is implemented.

  4. AlxDesign
    Member
    Posted 6 years ago #

    Thanks for that LenK. I will surely use this function on my upcoming themes.

    <?php if (is_page('x')) : ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    That one was really nice and simple. Thanks again.

  5. gavpedz
    Member
    Posted 5 years ago #

    This is great i am am having a bit of trouble though the forum which is the page in question does not stretch across the whole page.
    http://www.iamlizard.co.uk/?page_id=99

    any ideas?

  6. maoarana
    Member
    Posted 5 years ago #

    gavpedz I have the same problem you mention, how do you fix it???

  7. mentor@deeyes
    Member
    Posted 5 years ago #

    Lenk,

    Thank you so much for the solution. But, I don't see a file under 'wp-content' in the name of my newly created page. I only see page.php and I suppose, this is NOT the page I should directly work with right. From what I read from your post, page.php is only a template. Please correct me if I am wrong. And another question I have is, where do I find the ID number of the page?

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

  8. mentor@deeyes
    Member
    Posted 5 years ago #

    ###UPDATE###

    Lenk,

    I found the answer myself. I am able to remove the sidebar on this page but, as others mentioned, I am not able to expand the content of this page to the full width of this page. Can you help me how could I do this?

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

  9. esmi
    Forum Moderator
    Posted 5 years ago #

    @mentor: Page Templates

  10. esmi
    Forum Moderator
    Posted 5 years ago #

    @gavpedz:

    i am am having a bit of trouble though the forum which is the page in question does not stretch across the whole page

    Your forum is inside a div with the class 'Sheet'. This div (which incidentally seems to be defined twice in your css file) has a fixed with of 800px.

  11. t31os
    Member
    Posted 5 years ago #

    Use the if/else where you render you container also.....

    I'd personally use this shorter version for the page conditional..

    <?php if (!is_page('x')) : get_sidebar(); endif; ?>

    Then do this for your DIV container...

    EXAMPLE DIV...
    <div class="SomeClassName">

    EXAMPLE WITH CONDITIONAL..
    <div class="<?php if (!is_page('x')) : ?>SomeClassName<?php else : ?>AnotherClassName<?php endif; ?>">

    Change the names of course... SomeClassName & AnotherClassName (purely example names).

    Set "AnotherClassName" to a larger width... which only applies it's your particular page that doesn't include the sidebar... :)

  12. mentor@deeyes
    Member
    Posted 5 years ago #

    t31os,

    I have no developer background. I presume that your 'div class' example is to expand the content to the whole page width. I also assume that I do this in the 'page.php' file? If not, please advise me where do I make these additions to.

    Thank you.

    Mentor@Deeyes
    http://www.deeyes.net

  13. t31os
    Member
    Posted 5 years ago #

    Where's you'd normally have...
    <?php get_sidebar();?>

    You put the first condition...
    <?php if (!is_page('x')) : get_sidebar(); endif; ?>

    Then wherever you have the container/wrapper DIV..... like in the example (here it is again).
    <div class="myclass">

    Switch that for...
    <div class="<?php if (!is_page('x')) : ?>myclass<?php else : ?>myclasswider<?php endif; ?>">

    Basically when you on page X where X is the number or page name the sidebar is not shown and the class for the container DIV is switched to (in the new example) "myclasswider", and uses the class "myclass" when showing the sidebar..

    It's a little confusing when using an example name....

    So when the sidebar is shown...
    <div class"myclass">

    When the sidebar is not shown..
    <div class"myclasswider">

    You then accompany that with css to change width... (again another example)..

    .myclass {
    width:800px
    }
    .myclasswider {
    width:1000px
    }

    Not sure i can explain it any more simply, so hope that helps...

  14. kirk34
    Member
    Posted 5 years ago #

    Newbie Here,

    Here is my page.php code can someone help me, I tried to follow the example but Im just not that good with php or css, what Im trying to do is make a page without the sidebar included in it and to enlarge the page, any suggestions would be greatly appreciated?

    <?php get_header(); ?>
    <div class="contentLayout">
    <div class="content">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="Post">
    <div class="Post-body">
    <div class="Post-inner article">
    <?php ob_start(); ?>
    <h2 class="PostHeaderIcon-wrapper">
    <img src="<?php bloginfo('template_url'); ?>/images/PostHeaderIcon.png" width="26" height="26" alt="PostHeaderIcon" />
    <span class="PostHeader">" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">
    <?php the_title(); ?>
    </span>
    </h2>
    <?php $metadataContent = ob_get_clean(); ?>
    <?php if (trim($metadataContent) != ''): ?>
    <div class="PostMetadataHeader">
    <?php echo $metadataContent; ?>

    </div>
    <?php endif; ?>
    <?php $icons = array(); ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php the_time(__('F jS, Y', 'kubrick')) ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php _e('Author', 'kubrick'); ?>: "><?php the_author() ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (0 != count($icons)): ?>
    <div class="PostHeaderIcons metadata-icons">
    <?php echo implode(' | ', $icons); ?>

    </div>
    <?php endif; ?>
    <div class="PostContent">
    <?php if (is_search()) the_excerpt(); else the_content(__('Read the rest of this entry »', 'kubrick')); ?>

    </div>
    <div class="cleared"></div>
    <?php $icons = array(); ?>
    <?php if (!is_page()) : ?>
    <?php ob_start(); ?>
    <?php printf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?>
    <?php $icons[] = ob_get_clean(); ?>
    <?php endif; ?>
    <?php if (!is_page() && get_the_tags()) : ?><?php ob_start(); ?>
    <?php the_tags(__('Tags:', 'kubrick') . ' ', ', ', ' '); ?>
    <?php $icons[] = ob_get_clean(); ?><?php endif; ?>
    <?php if (!is_page() && !is_single()) : ?><?php ob_start(); ?>
    <?php comments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '', __('Comments Closed', 'kubrick') ); ?>
    <?php $icons[] = ob_get_clean(); ?><?php endif; ?>
    <?php if (0 != count($icons)): ?>
    <div class="PostFooterIcons metadata-icons">
    <?php echo implode(' | ', $icons); ?>

    </div>
    <?php endif; ?>

    </div>

    </div>
    </div>

    <?php endwhile; endif; ?>

    </div>
    <div class="sidebar1">
    <?php include (TEMPLATEPATH . '/sidebar1.php'); ?>
    </div>

    </div>
    <div class="cleared"></div>

    <?php get_footer(); ?>

  15. kirk34
    Member
    Posted 5 years ago #

    I will pay for help with this, Im sure its pretty easy but I cant get it to work right?

  16. newbirddesign
    Member
    Posted 5 years ago #

    I'm trying to use this technique to add 3 columns under the header on my homepage but no where else

    i get half of this to work it creates the CSS for my 3 columns but it shows up on every page - any help would be great

    <div class="<?php if (!is_page('home')) : ?>contentL<?php else : ?>blank<?php endif; ?>"></div>
    <div class="<?php if (!is_page('home')) : ?>contentM<?php else : ?>blank<?php endif; ?>"></div>
    <div class="<?php if (!is_page('home')) : ?>contentR<?php else : ?>blank<?php endif; ?>"></div>

    .blank {
    width:0px;
    height: 0px;
    }

    .contentL{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-left: 40px;
    float:left;
    }

    .contentM{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-left: 20px;
    float:left;
    }
    .contentR{
    width:270px;
    height:238px;
    margin-top:20px;
    margin-right: 20px;
    margin-left: 20px;
    float:left;
    }

  17. kirk34
    Member
    Posted 5 years ago #

    Ok I got the example done above but when I go to create a new page and use the dropdown box to change the theme it only gives me one choice the default theme, any suggestions?

  18. newbirddesign
    Member
    Posted 5 years ago #

    this is what i used as a solution for my problem

    <?php
    if(is_page('welcome')) {
    print '<div class="contentL">';
    include("contentL.php");
    print '</div>';
    print '<div class="contentM">';
    include("contentM.php");
    print '</div>';
    print '<div class="contentR">';
    include("contentR.php");
    print '</div>';
    }
    ?>

  19. t31os
    Member
    Posted 5 years ago #

    Or, to make it a little easier to read you could do...

    <?php if(is_page('welcome')) : ?>
      <div class="contentL"><?php include('contentL.php');?></div>
      <div class="contentM"><?php include('contentM.php');?></div>
      <div class="contentR"><?php include('contentR.php');?></div>
    <?php endif;?>

    To post code in the forum here, please use backticks (top left, next to the 1 key)... as indicated in the post box (the one you type into).

    Or use a pastebin.
    http://wordpress.pastebin.ca/

  20. newbirddesign
    Member
    Posted 5 years ago #

    hey man thanks a lot I really appreciate your help.

  21. newbirddesign
    Member
    Posted 5 years ago #

    hello again t31os im getting a strange problem with my divs it is adding a scroll bar to each div in firefox and in IE it doesn't push the content of the blog down (it just sites on top of it) ill past my

    header.php

    <!-- header START -->
    <div id="header">
    
        <div id="caption"><div id="navigation">
    		<ul id="menus">
    			<li class="<?php echo($home_menu); ?>"><a class="home" title="<?php _e('Home', 'inove'); ?>" href="<?php echo get_settings('home'); ?>/"><?php _e('Home', 'inove'); ?></a></li>
    			<?php
    				if($options['menu_type'] == 'categories') {
    					wp_list_categories('depth=2&title_li=0&orderby=name&show_count=0');
    				} else {
    					wp_list_pages('depth=2&title_li=0&sort_column=menu_order');
    				}
    			?>
    			<li><a class="lastmenu" href="javascript:void(0);"></a></li>
    		</ul>
    </div></div>
    
    <?php if(is_page('welcome')) : ?>
      <div class="contentL"><?php include('contentL.php');?> </div>
      <div class="contentM"><?php include('contentM.php');?> </div>
      <div class="contentR"><?php include('contentR.php');?> </div>
    <?php endif;?>

    style.css

    .contentL{
    	width:270px;
    	height:238px;
    	margin-top:20px;
    	margin-left: 40px;
    	float:left;
    	overflow:auto;
    	}
    
    .contentM{
    	width:270px;
    	height:238px;
    	margin-top:20px;
    	margin-left: 20px;
    	float:left;
    	overflow:auto;
    	}
    .contentR{
    	width:270px;
    	height:238px;
    	margin-top:20px;
    	margin-right: 20px;
    	margin-left: 20px;
    	float:left;
    	overflow:auto;
    	}

    ContentL.php,ContentM.php,ContentR.php

    these pages just are completly blank with just some filler text no html or php

    thanks in advanced!

  22. t31os
    Member
    Posted 5 years ago #

    They will do that, you have overflow:auto ...

    Which in simple terms basically means, when the content in this element exceeds the width of the element then automatically add scrollbars.

    That will naturally happen...

    What would you like it to do?

  23. newbirddesign
    Member
    Posted 5 years ago #

    basically word wrap inside the contentL,M,R div

    do you have any ideas about the IE problem?

  24. newbirddesign
    Member
    Posted 5 years ago #

    hey also, i see that you are very knowledgeable in PHP do have any pointers on good places to start to learn?

  25. t31os
    Member
    Posted 5 years ago #

    You'd be best off starting with HTML and CSS, for starters it's easier, and secondly knowing PHP without the HTML and CSS is not going to be much use when using WordPress, at least not in my opinion.

    Learn by doing, search when you get stuck... Start a project, whether it be a 4 page website or a basic CMS, write it yourself and learn as you go...

    Google is your friend...

    W3Schools is a good site for info.
    http://www.w3schools.com/Xhtml/
    http://www.w3schools.com/css/

    Sitepoint.com i find have some of the best online guides available.

    Once you grasp HTML and CSS you'll be able to understand the structure of a webpage, and be able to build pretty much any design you like... of course graphics are another subject. I still learn new things about HTML and CSS now and i've been at it on and off for years, and pretty sure it's the same for any web language, as they're constantly evolving.

    When i started building webpages it was back when Geocities (free host) had a basic "Web Builder" (years ago now) .. a browser based page designing utility, you move boxes around the screen, enter text and it creates the HTML for you...etc etc... lol, shocking code of course...

    Then moved onto building with tables in frontpage, which i stuck with for quite a while doing websites for clans i played in etc.... granted they weren't mind blowing designs but it was enjoyable picking scripts apart and learning how to format a design to make it work, and learning how different elements effect each other...

    HTML has come a long way since then though. It's far easier to use, and now we have CSS to accompany it, which while great can be a little overwhleming if you're just starting to write code.

    Find a decent app for HTML and it'll make learning alot easier..

    This looks good since it's free!....
    http://www.w3.org/Amaya/

    Not used it, but looks pretty good..

  26. newbirddesign
    Member
    Posted 5 years ago #

    Thanks a lot for the advice and the link references they will come in handy. i think i have a pretty good grasp on HTML and CSS its really just the PHP that is new to me. but basically going back three posts ago do you know a solution to my problem with my divs?

  27. t31os
    Member
    Posted 5 years ago #

  28. newbirddesign
    Member
    Posted 5 years ago #

    I am still having that problem its not the overflow or the white-space. I think it might have somthing to do with the .php file that it is calling with the text. if i make an error in the php of header.php the error message is contained within the div but the text that i have in the "contentL.php" still overflows across the page. any ideas!?

  29. Syed Balkhi
    Member
    Posted 5 years ago #

    Browser Variation is not a php problem. It is a css problem. Try switching the use of margins to padding or paddings to margin.... because that is what often causes ...

  30. newbirddesign
    Member
    Posted 5 years ago #

    nah that didn't change anything. i really don't think in this case it has something to do with the CSS, anymore info would be appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic