• Resolved JakeDellon

    (@jakedellon)


    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
    ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • This should work assuming page-6 is the post-title of the page.

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

    https://codex.www.ads-software.com/Function_Reference/is_page

    Thread Starter JakeDellon

    (@jakedellon)

    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.

    this should do (replaces all your posted code):

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

    Thread Starter JakeDellon

    (@jakedellon)

    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.

    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?

    Thread Starter JakeDellon

    (@jakedellon)

    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.

    Thread Starter JakeDellon

    (@jakedellon)

    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.]

    Thread Starter JakeDellon

    (@jakedellon)

    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(); ?>

    remove this bit:
    get_sidebar( $name );

    Thread Starter JakeDellon

    (@jakedellon)

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Sidebar on one page only – Template "Blank"’ is closed to new replies.