• I am using code I found online to exclude a category from a listing of the most recent entry titles. Now I want to only show the last three entries as well. How do I include the limitation to my code?

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php if ( !(in_category('18')) ) { ?>

    <a>(<?php the_time('M. d'); ?>) <?php the_title(); ?></a>

    <?php } ?>

    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.
    <?php endif; ?>

    Thanks so much for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You’re looking for Query_Posts [wordpress codex], which can easily limit categories and posts.

    You’d use <?php query_posts('cat=-2&showposts=10') ?> for example, if you wanted to exclude category 2 and show only 10 posts.

    Thread Starter wstewart1

    (@wstewart1)

    Thanks for the quick reply! I’ll try that and see what happens.

    i tried several code from QUERY POSTS u pasted.
    i tried to exclude an category by ID
    but all i got was , that they are loaded in a loop over 100 times.

    how to exclude all categories on mainpage except cat id 1 ??

    you can help me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude category AND limit posts?’ is closed to new replies.