php - How do I remove the most recent post from the sidebar in Wordpress? -


on both front page , blog page - sidebar shows recent post, find doesn't duplicated against same post expanded on main page.

this code sidebar:

<div class="blog-sidebar"> <?php query_posts('showposts=5'); ?> <?php while (have_posts()) : the_post(); ?>     <div class="blog-sidebar-feature">         <?php if ( has_post_thumbnail() ) { ?>             <div class="blog-sidebar-image"><a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_post_thumbnail('medium'); ?></a></div>         <?php         }         ?>         <div class="blog-sidebar-content">             <p class="date"><?php the_time('f j, y') ?></p>             <h3 <strong><?php      foreach((get_the_category()) $category) {  echo $category->cat_name . ' ';      }      ?></strong></h3>     <h2 <p><a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title();              ?></a></p></h2><?php echo get_excerpt(166); ?>         </div>     </div> <?php endwhile;?> <br /> <?php wp_pagenavi(); ?> </div> 

and relevant code how blog appears on home page:

<div class="blog-sidebar">     <div class="blog-sidebar-feature">         <?php query_posts('orderby=date&order=desc&showposts=2'); ?>             <?php while (have_posts()) : the_post(); ?>             <?php if ( has_post_thumbnail() ) { ?>                 <div class="blog-sidebar-image"><a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_post_thumbnail('medium'); ?></a></div>             <?php             }             ?>             <div class="blog-sidebar-content">                 <p class="date"><?php the_time('f j, y') ?></p>             <h3 <strong><?php     foreach((get_the_category()) $category) {  echo $category->cat_name . ' ';      }      ?></strong></h3>                 <h2 <p><a href="<?php the_permalink() ?>"         rel="bookmark" title=""><?php the_title(); ?></a></p></h2><?php echo get_excerpt(166); ?>             </div>         <?php endwhile;?>     </div>  </div> <div id="connect">     <?php query_posts('page_id=1');       while (have_posts()): the_post();       the_content();   endwhile;   wp_reset_query(); ?> </div> 

is there way remove recent post sidebar when appears in full on main container? in advance help.

update v2

so want recent posts, not post showing in main content.

update v3:

this should work now. had change arguments of query_posts array make work.

try now:

<? global $wp_query; $skip_posts=array(); if (is_single()) //only exclude posts when single post shown $skip_posts[]=$wp_query->post->id; ?> <?php query_posts( array( 'showposts'=>5,'post__not_in'=>$skip_posts)); ?> 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -