WordPress.org

Forums

Problem getting sidebar on 'Single Post.php' (7 posts)

  1. abbelsap
    Member
    Posted 6 years ago #

    I've created a custom theme for my WordPress Blog, but i have a problem with getting the sidebar on the 'single.php' page.

    If i try to add '<?php get_sidebar(); ?>' it'll add the sidebar beneath the page. Here is the link to the page i'm reffering to: click
    So could anyone help me sorting this out? Thanks in advance!

    And here is the code for that specific page.

    <?php get_header(); ?>
    
    	<div id="content">
    		<div id="contentHeader">
    					<div id="siteDescription"><?php bloginfo('description'); ?>
    </div>
    		</div>
    	<div id="mainAlone">
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<!--
    		<div class="navigation">
    			<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
    			<div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
    		</div>
    		-->
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this entry &raquo;
    '); ?>
    
    				<?php link_pages('<strong>Pages:</strong> ', '
    ', 'number'); ?>
    
    			<!--	<p class="postmetadata alt">
    					<small>
    						This entry was posted	on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
    						and is filed under <?php the_category(', ') ?>.
    						You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed. -->
    
    						<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    							// Both Comments and Pings are open ?>
    							You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
    
    						<?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    							// Only Pings are Open ?>
    							Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site.
    
    						<?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    							// Comments are open, Pings are not ?>
    							You can skip to the end and leave a response. Pinging is currently not allowed.
    
    						<?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    							// Neither Comments, nor Pings are open ?>
    							Both comments and pings are currently closed.
    
    						<?php } edit_post_link('Edit this entry.','',''); ?>
    
    					</small>
    
    		</div>
    		</div>
    	<?php comments_template(); ?>
    
    	<?php endwhile; else: ?>
    
    		Sorry, no posts matched your criteria.
    
    <?php endif; ?>
    
    	</div>
    
    <?php get_footer(); ?>
  2. krembo99
    Member
    Posted 6 years ago #

    Fisrt oa all, in the code you pasted there is no sidebar reference .
    Second - It is probably a fixed width css problem, your sidebar just does not have enough space to be where it is supposed to be on the main page .
    And hird - when going to your link (and the nthe "about" page - the sidebar appears just fine :-)

  3. abbelsap
    Member
    Posted 6 years ago #

    No because i deleted it, when i DO add it, it will state the problem on the OP.

    If i try to add '<?php get_sidebar(); ?>' it'll add the sidebar beneath the page.

    But okay, i've added the function to display the sidebar. If you'll click my link again you'll see the problem.

    And like i said, it DOES appear fine on every other page, but just not on the 'single.php' page (you know the page for permalink, comments and stuff)

  4. krembo99
    Member
    Posted 6 years ago #

    well.. you are missing a div...
    the '<?php get_sidebar(); ?>' should come in a div on it's own .
    just open some other page (like archive.php) and see the DIV division there..

  5. abbelsap
    Member
    Posted 6 years ago #

    <?php get_header(); ?>
    
    	<div id="content">
    		<div id="contentHeader">
    					<div id="siteDescription"><p><?php bloginfo('description'); ?></p></div>
    		</div>
    		<div id="main">
    			<?php if (have_posts()) : ?>
    
    			 <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    	<?php /* If this is a category archive */ if (is_category()) { ?>
    			<h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
    
    	 	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    			<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
    
    		 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    			<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
    
    			<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    			<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
    
    		  <?php /* If this is a search */ } elseif (is_search()) { ?>
    			<h2 class="pagetitle">Search Results</h2>
    
    		  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    			<h2 class="pagetitle">Author Archive</h2>
    
    			<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    			<h2 class="pagetitle">Blog Archives</h2>
    
    			<?php } ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div>
    
    		<?php while (have_posts()) : the_post(); ?>
    		<div class="post">
    				<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    				<small><?php edit_post_link('Edit', '', ' | '); ?><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></small>
    
    				<div class="entry">
    					<?php the_content() ?>
                                             <br />
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    That's the code of archive.php, as you can see, i don't have it in a DIV division. However it does display the sidebar fine on every other page as you can see, but just not on the single.php page..
    It's really frustrating because i can't seem to solve it.

  6. krembo99
    Member
    Posted 6 years ago #

    Like i said in the first post, you do not have enough place declares,
    And like I said in the second , a div is missin declare.
    So just replace your mainAlone in the csss with this :

    #mainAlone {
    margin: 15px 15px;
    width: 430px;
    float: left;
    }

    and your problem will probably be resolved

  7. krembo99
    Member
    Posted 6 years ago #

    I see that DID resolve your problem, It would be nice to tick this thread as [RESOLVED] so people who help here will have one less red alarm ..
    (Not to mention a small "thank you" which most of us do not even expect anymore..)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags