Support » Themes and Templates » Exclude posts already used

  • I found plenty different tutorials on how to exclude a single post from the loop, but none seems to work for me.

    I’m modifying the great Arthemia 2.0 Free theme to my needs (take a look at the demo page). What I want is to make posts from Headlines and Featured categories show as well in the main loop (the one below category bar). However, I’d like to exclude the latest post from Headlines and four latest posts from Featured, as they are already shown above.

    So far my code for Headlines looks like this (the incl_object_id thing is WPML stuff):

    <?php $my_query = new WP_Query("showposts=1&category_name=".icl_object_id(Headlines,'category'));
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$do_not_duplicate = $post->ID; ?>

    Then the main loop looks like this:

    <?php
    		$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    		query_posts("cat=&paged=$page&posts_per_page=5");
    	?> 
    
    	<?php while (have_posts()) : the_post();
    	 ?>

    I know I can make the theme exclude the Headlines category in the latter loop altogether ('query_posts("cat=-4&paged=$page&posts_per_page=5");

    However, I want the category to show just fine, only without the first post. Anyone willing to help? Thanks in advance

  • The topic ‘Exclude posts already used’ is closed to new replies.