I have a featured posts slider, which uses the 'featured' tag. I have a query for this which grabs the 3 most recent posts with this tag and shows them in the slider. Below this, I have a list of 10 or so most recent posts across all categories. How would I write a query to exclude the 3 most recent posts with the 'featured' tag, as these are already in the slider (don't want post duplication), but then when they drop off the slider (i.e they're now the 4th most recent 'featured' post etc), they appear in the post list?
EDIT: Here is my code - I've written a shortcode so I can drop it into any page/widget/etc I want but the query for getting the 3 most recent 'featured' posts is here:
posts_per_page=3&post_type=post&tag=featured
and the query which grabs the 10 most recent posts across all categories is:
posts_per_page=10&post_type=post
Hope that's helpful :)
Thanks :)
EDIT #2: Used @Chip Bennet's answer, inside my short code which almost works but it only excludes one of the featured posts (most recent I think), not all 3 that are on the slider. Here is the code:
function loopShortcode($atts) {
$excludeFeaturedPosts = array(
'tag' => 'featured',
'posts_per_page' => 3
);
$featured_posts = new WP_Query($excludeFeaturedPosts);
$featured_post_ids = array();
foreach ( $featured_posts as $featured_post ) {
$featured_post_ids[] = $featured_post->ID;
}
wp_reset_query();
// Defaults
extract(shortcode_atts(array(
"posts_per_page" => '', // query parameters are defined by the user when you add the shortcode into the page
"post_type" => ''
), $atts));
$query_args = array(
"posts_per_page" => $posts_per_page,
"post_type" => $post_type,
"post__not_in" => $featured_post_ids
);
$listedPosts = new WP_Query($query_args);
// rest of short code content, e.g loop, output etc
return $output;
wp_reset_query();
} // end shortcode function