Excluding current post / url in WordPress Loop
A very quick post today but hopefully this will help a few people.
WordPress is a great tool for a small website requiring regular editing. While using the loop i wanted to find a way to exclude the current pages url from a list of links. There is no point in a page linking to itself!
By using the the post__not_in function its easy to do.
<?php query_posts(array('showposts'=> 6,'post__not_in' => array($post->ID)));
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
Did it work? Any problems? Post a comment below.

February 1st, 2010 at 9:42 am
Hi there,
Great post.
I wonder if you could show me how i would need to add this into my loop?
Been trying to find the answer for this for ages!