WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sidebar on one page only - Template "Blank" (11 posts)

  1. JakeDellon
    Member
    Posted 4 months ago #

    I took over an existing, WordPress site (as in, I did not build it). The template they used is called "Blank". I do not have the typical WordPress functions, like the one I need - selecting pages for the sidebar.

    Here's what I gleaned from the forums, to call the sidebar to my one page. What I need is how to stop it from showing up on the other pages. The code is written in the templates "pages.php". Any other code options welcomed!

    Thanks!

    <?php get_sidebar( $name );
    if ( is_page( 'page-6' ) ) :
    get_sidebar();
    else :
    get_sidebar(); /*can I put something here to prevent the sidebar from showing on all the other pages? */
    endif
    ?>

  2. graphical_force
    Member
    Posted 4 months ago #

    This should work assuming page-6 is the post-title of the page.

    <?php get_sidebar( $name );
    if ( is_page( 'page-6' ) ) {
    get_sidebar();
    }
    ?>

    http://codex.wordpress.org/Function_Reference/is_page

  3. JakeDellon
    Member
    Posted 4 months ago #

    The side bar is still appearing on my other pages. This is probably difficult to diagnose, but could the sidebar be called up somewhere else, globally? I've check all the pages, but can't see it. I have a widget plug-in for setting the sidebar widget per page, but where there are no widgets, the sidebar border appears, just empty.

    See: Contact pageOf course there are other pages it appears this way, too.
    Correct showing on the blog page:
    BlogWhich is my intent to have it here only.

    Don't ask why the site was set up this way. I inherited it.

  4. alchymyth
    The Sweeper & Moderator
    Posted 4 months ago #

    this should do (replaces all your posted code):

    <?php if ( is_page( 'page-6' ) ) get_sidebar(); ?>

  5. JakeDellon
    Member
    Posted 4 months ago #

    The code recommended above is what I posted. I formatted the sidebar with a css border. The sidebar widgets appear as I want them in the page called "Blog". But, an empty border, shows up on all the other pages. I just removed the css format, so nothing appears on the other pages. This remains a mystery.

  6. alchymyth
    The Sweeper & Moderator
    Posted 4 months ago #

    what is the full code of the used template ?

    the page's formatting might need to be adapted if the sidebar is removed.

    can you post a link to the site?

  7. JakeDellon
    Member
    Posted 4 months ago #

    If you look at the string, I posted the Contact page and Blog page. But now I removed the css border so it no longer appears. My goal was to have a nice border, matching the site, on the previous posts and archive list. But, the border worked on the blog page, but also appeared without the widgets on all the other pages. I put it back, so you can see what I mean.

  8. JakeDellon
    Member
    Posted 4 months ago #

    Here's the page.php code:

    <?php get_header(); ?>
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    
    			<div id="pagetitle"><?php the_title(); ?></div>
    
    			<!-- <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?> -->
    
    			<div class="entry">
    
    				<?php the_content(); ?>
    
    				<?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
    
    			</div>
    
    			<?php edit_post_link('Edit', '<p>', '</p>'); ?>
    
    		</div>
    
    		<?php endwhile; endif; ?>
    
    <?php get_sidebar( $name );
    if ( is_page( 'blog' ) )
    get_sidebar();
    ?>
    
    <?php get_footer(); ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

  9. JakeDellon
    Member
    Posted 4 months ago #

    Sorry alchymyth, I got a WP moderator kick back that my code was parsed. Here it is between back ticks.

    <?php get_header(); ?>
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    
    			<div id="pagetitle"><?php the_title(); ?></div>
    
    			<!-- <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?> -->
    
    			<div class="entry">
    
    				<?php the_content(); ?>
    
    				<?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
    
    			</div>
    
    			<?php edit_post_link('Edit', '<p>', '</p>'); ?>
    
    		</div>
    
    		<?php endwhile; endif; ?>
    
    <?php get_sidebar( $name );
    if ( is_page( 'blog' ) )
    get_sidebar();
    ?>
    
    <?php get_footer(); ?>
  10. alchymyth
    The Sweeper & Moderator
    Posted 4 months ago #

    remove this bit:
    get_sidebar( $name );

  11. JakeDellon
    Member
    Posted 4 months ago #

    Yay!! You're the best. Thank you so much!!!!!

Reply

You must log in to post.

About this Topic