Forums

excluding a category from a recent post with thumbnail list (4 posts)

  1. obakitch
    Member
    Posted 2 years ago #

    Hello I have a thumbnail list that I am using as my recent post list. I need to exclude one or more categories from the list. Thank you in advance... the code is below as well as the url is the list to the far right

    http://rebelvision.com/newrebel/print

    <ul class="thumb_recent" >
    <?php query_posts('showposts=5'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php $thumbnail = get_post_meta($post->ID, 'thumbnail', true); ?>

  2. " title="<?php the_title(); ?>">
    <img src="<?php echo $thumbnail; ?>" alt="<?php the_title(); ?>" />
    <span><!--<?php the_title(); ?>--></span><p>
  3. <?php endwhile; endif; ?>

  • esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Try:

    <?php
    $excl_cats = array(2,6);
    $args= array(
    	'posts_per_page' => 5,
    	'category__not_in' => $excl_cats
    );
    query_posts($args); ?>
  • jessn
    Member
    Posted 2 years ago #

    <?php query_posts('showposts=5&cat=-4'); ?>

    Change 4 to the ID number of the category that you want to exclude, and make sure to keep the minus sign before it.

  • obakitch
    Member
    Posted 2 years ago #

    AAAAAHHH Thank you Jessn that did the trick ...its always the simplest things that I miss

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags