• Hi folks
    Some small questions:

    1. How do I get the 2nd and 3th last entry?

    <?php $cat_posts = new WP_Query('category_name=Basecamp&orderby=post_date&posts_per_page=3'); ?>
    <?php if($cat_posts->have_posts()) : ?><?php while($cat_posts->have_posts()) : $cat_posts->the_post(); ?>
    
    <?php endwhile; ?>
    <?php endif; ?>

    This gives me the last 3 posts, and I actually need the 2 previous ones

    ————————

    2. Using the same kind of code, how can I get all categories listed except one that’s called Twitter (in my case)

    Thanks in advance
    Jelle

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php $cat_posts = new WP_Query('category_name=Basecamp&orderby=post_date&posts_per_page=3 exclude=4'); ?>
    <?php if($cat_posts->have_posts()) : ?><?php while($cat_posts->have_posts()) : $cat_posts->the_post(); ?>
    
    <?php endwhile; ?>
    <?php endif; ?>

    change the exclude id to what it actually is in the above

    Thread Starter Jellelle

    (@jellelle)

    Thanks, but it’s not working. Maybe I need to be more precise ??

    I need to show all the last 4 post titles of all categories except the ones of category ID5
    <?php $cat_posts = new WP_Query('orderby=post_date&posts_per_page=4&exclude=5'); ?>

    This doesn’t work for me

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Some ‘Category’ questions’ is closed to new replies.