Wordpress: please help with get_posts()

Discussion in 'PHP' started by marin, Jun 3, 2008.

  1. #1
    Hello
    I hope somebody will be able to help me, because on wordpress.org nobody replied :)

    On my home page i want to display my latest 5 pages OR posts, with an exception of posts from category 3.

    I use this code:
    	<?php 
    $postslist = get_posts('post_type&numberposts=5&offset=2');
     foreach ($postslist as $post) : setup_postdata($post);
    ?>  
    
    <?php if (in_category('3')) continue; ?>
    
     <div id="posti">
    
    <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>  
     
    <?php the_content_limit(150,'Več &rarr;'); ?>
    
     </div>
    
     <?php endforeach; ?> 
    Code (markup):
    But the problem is, when in the last 5 posts there is one from category 3, the code shows just 4 posts.
    Do you have any idea how to do this, that it will always display 5 posts, no matter if there are any from category 3?

    Thanks in advance for your time, Marin
     
    marin, Jun 3, 2008 IP