Search this website:


Excluding current title and URL in loop - WordPress

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(); ?>
  • <?php the_title(); ?>
  • <?php endwhile;?>

    Did it work? Any problems? Post a comment below.

    Comments

      http://promgazarm.ru , , , -1, -2   http://promgazarm.ru/tags/  1127, -50, ,

    By 7qu35r0d on 21st February 2012

    The loans seem to be important for people, which want to ground their career. By the way, that’s easy to receive a consolidation loan.

    By Tami18Gay on 24th March 2012

    Every american history essays firm must hire singly academic specialists. students naturally are going to order the highest quality college essays and it’s normal.

    By SusieWheeler25 on 30th March 2012

    Comment Form:

    < Back to view all blog entries
    • 17th May 2012 @mikekus is @workfu a personal or client project?
    • 16th May 2012 Cracking font for the right scenario - http://t.co/qwqkbBWD Meet strangelove
    • 16th May 2012 @graemebenzie how's it going down there?
    • 15th May 2012 @mcaulay About all projects are fixed so not really an issue. Bit archaic but these r pen / paper to an spreadsheet. Modern cool way huh?
    • 15th May 2012 @mcaulay Right ok, so they dropped that feature then...(never used it) Why?
    • 15th May 2012 @mcaulay What you guys using ?
    • 15th May 2012 @mcaulay Got ya. Guess theres no third party that can integrate with it ?
    • 15th May 2012 Loving basecamp by @37signals and have been for years, The best Project managing app out there, new design takes it up 2 or 3 notches too
    • 15th May 2012 Lovely agency site -http://www.levo.com.au very nice #bigstuff
    • 11th May 2012 @debutmarketing Strangley enough Julie not a client more of a potential client. All sorted now thankfully. #searchenginescanbedangerousfolks
    @mediasurgery