Making a page template in WordPress with one sidebar

Discussion in 'WordPress' started by pratik, Feb 11, 2011.

  1. #1
    Hi there,

    As the title says... I have a theme which has two sidebars. Which is the default template.
    I need a page template with just one sidebar. This will give me more space for content.

    The site on which the theme is used is
    www.applykar.com
    Code (markup):
    I had done this previously but don't exactly remember how :(

    Any help would be appreciated :)
     
    pratik, Feb 11, 2011 IP
  2. BFiggy

    BFiggy Member

    Messages:
    89
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    25
    #2
    Do you want the whole site to be just one sidebar, or just a single page? If you want the whole site to be 1 side bar you can open up the "sidebar.php" and delete the following code (the right sidebar). After that you will need to edit the css for <div class="sidebar left-sidebar"> and set it to the new sidebar width.

    P.S. I would back everything up first.

    <div class="span-4 last">
            
    		<div class="sidebar right-sidebar">
    		
    		<?php
    		if(get_theme_option('rssbox') == 'true') {
    			?>
        			<div class="socialboxes">
        				<a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/rss.png"  alt="RSS Feed" title="RSS Feed" style="vertical-align:middle; margin-right: 5px;"  /></a><a href="<?php bloginfo('rss2_url'); ?>"><?php echo get_theme_option('rssboxtext'); ?></a>
        			</div>
        			<?php
        		}
        	?>
        	
        	<?php
        		if(get_theme_option('twitter') != '') {
        			?>
        			<div class="socialboxes">
        				<a href="<?php echo get_theme_option('twitter'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/twitter.png"  alt="<?php echo get_theme_option('twittertext'); ?>" title="<?php echo get_theme_option('twittertext'); ?>" style="vertical-align:middle; margin-right: 5px;"  /></a><a href="<?php echo get_theme_option('twitter'); ?>"><?php echo get_theme_option('twittertext'); ?></a>
        			</div>
        			<?php
        		}
        	?>
        	
                <?php if(get_theme_option('ads_125') != '') {
            		?>
            		<div class="sidebaradbox125">
            			<?php sidebar_ads_125(); ?>
            		</div>
            	<?php } ?>
                
              	
    			<ul>
    				<?php  if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 2') ) : ?>
                    
                    <li><h2>Archives</h2>
    					<ul>
    					<?php wp_get_archives('type=monthly'); ?>
    					</ul>
    				</li>
    				<?php wp_list_bookmarks(); ?>
                            
    				
    	
    				<?php endif; ?>
    			</ul>
    		<?php if(get_theme_option('ad_sidebar2_bottom') != '') {
    		?>
    		<div class="sidebaradbox">
    			<?php echo get_theme_option('ad_sidebar2_bottom'); ?>
    		</div>
    		<?php
    		}
    		?>
              
    		</div>
    	</div>
    PHP:
     
    BFiggy, Feb 11, 2011 IP
    pratik likes this.
  3. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Thanks BFiggy for the reply...
    I just want to delete the sidebar on few pages... hence I need a new page template... so that i can select while posting / add a page..
     
    pratik, Feb 11, 2011 IP
  4. BFiggy

    BFiggy Member

    Messages:
    89
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    25
    #4
    Ahh I see. In that case, you can create a second sidebar (name it something like "sidebar2.php") and add this at the very top of the PHP file
    <?php /* Template Name: Second Sidebar
    */ ?>
    PHP:
    Then when you create a new page select "Second Sidebar" on the right side where it says "Page Attributes" > "Template"
     
    BFiggy, Feb 11, 2011 IP
  5. kiramanic

    kiramanic Peon

    Messages:
    205
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The problem with your theme is that both sidebars are in the one file, sidebar.php, so just creating a new page template isn't going to work.

    What I'd personally do is split the two sidebars into two separate files, then in your existing templates add an extra sidebar call so they're both in there and everything is back to normal. THEN you can create a new page template that only includes one of them. Info on creating page templates is here, and some info on calling sidebars over here.
     
    kiramanic, Feb 11, 2011 IP
    pratik likes this.
  6. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #6
    Thanks kiramanic for your reply...
    this is what exactly I was looking for...

    I will try to make the template now!!
     
    pratik, Feb 12, 2011 IP
  7. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #7
    I have managed to delete the sidebar...
    But I don't understand how to delete the vertical line...
    please see here

     
    pratik, Feb 16, 2011 IP