• I have a loop at the bottom of the page that cycles through randomly grabbing more posts from that category and displaying them as thumbnails. I’m able to get it work fine, but I can’t figure out how to exclude the current post that is being displayed. Here’s my code


    <?php
    global $wp_query;
    $cat_ID = get_the_category($post->ID);
    $cat_ID = $cat_ID[0]->cat_ID;
    query_posts('cat='.$cat_ID.'&showposts=14&orderby=rand');
    ?>
    <?php while (have_posts()) : the_post(); ?>
    <div id="categoriesThumb" onclick="location.href='<?php the_permalink(); ?>';" style="cursor: pointer;">
    <?php if ( has_post_thumbnail()) : ?>
    " title="<?php the_title_attribute(); ?>" >
    <?php the_post_thumbnail(array(85,58)); ?>

    <?php endif; ?>

    ">
    <?php the_title(); ?>
    </div>
    <?php endwhile; ?>

    I’ve tried various ways to get it to exclude that post, but I can’t seem to figure it out. Any suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude Current Post from Query’ is closed to new replies.