Before I start, you should never make use of query_posts
unless your intention is to break almost everything on your page :-)
Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination).
To accomplish this, you should use WP_Query
, and the post__not_in
parameter. You must first get an array of the all the post ID's on the page, and then use that to exclude those posts in your query
You can try something like this on your page
$post_ids = wp_pluck_list($wp_query->posts, 'ID');
$args = array(
'posts_per_page' => 1,
'cat' => 1,
'post__not_in' => $post_ids
);
$q = new WP_Query($args);
if ($q->have_posts()) {
while($q->have_posts()) {
$q->the_post();
//Your loop
}
wp_reset_postdata();
}