• On my sidebar.php file I have added code to include the most recent post from 1 category. This works: it shows the correct post in the sidebar.

    However, it also clears all of my Static Pages of their unique content and replaces that content with the same post that the sidebar calls.

    Here is the code I use in the sidebar.php file to call the most recent post with category ‘Event’

    <?php query_posts('cat=Events'); ?>
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    					<small><?php the_time('F jS, Y') ?> <!-- bye <?php the_author() ?> --></small>
    						<div class="entry">
    							<?php the_content('Read the rest of this entry &raquo;'); ?>
    						</div>
    			</div>
    
    		<?php endwhile; ?>
    	<?php endif; ?>

    Anyone know why this code would cancel out the static pages content and redisplay the post in its place?
    thanks!

Viewing 1 replies (of 1 total)
  • Some themes call the sidebar function(s) first then display the main content of the page. If the theme you are using is working in this fashion then the code limiting the sidebar post display is also limiting in exactly the same fashion the main content.

    Also, if this the case, you can try moving the “sidebar” below the main content section of your index.php file and see if that corrects the issue …

    It’s a bit of a guess, but a link to your blog, or perhaps the theme you are using would help further.

Viewing 1 replies (of 1 total)

The topic ‘Adding Loop in sidebar makes posts appear on static pages…’ is closed to new replies.