You have already figured it out but I will post an answer anyway for others.
To alter a Query, that has already been set, the easiest way is to use query_posts().
Note this will only work if run before the loop.
<?php
query_posts(array(
'post__not_in' => array(1,2,3,4,'...')
));
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php // Loop content here ?>
<?php endwhile; else: ?>
<?php // No posts message here ?>
<?php endif; ?>
Related Posts:
- how to override woocommerce specific loop or archive-product.php [closed]
- Getting Post Comments for post ID using WP_Query() and a Custom Loop?
- Archive Listings Filtered by Date Values in a Custom Field/Post Meta?
- How can I save an array from a random post sequence for later use?
- How can I create an alternative home page?
- Pagination Not working on Home Page with 2 Query
- Prevent WordPress from loading comments
- Show default content if custom WP_Query has no posts
- How to find if a post with custom_field == X exists?
- WP_Query with the “offset” argument
- Last post is not showing up
- get_option issues
- Impossible to get Attachments Outside WordPress?
- Show post page only if the user has bought a specific product
- Adding Pagination on a Custom Author Page
- Exclude custom taxonomy tag from loop
- Sub-loop / nested loops Best Practices
- Loop through custom fields with similar label / common chars in label
- Pagination Issues using WP_Paginate Plugin
- Fastest way to get the comment and ping total count for a post
- CPT Loop with ACF and passing ID between Loops
- How can I display a PHP foreach loop’s answers by AJAX
- toggle Multiple Loop with tittle
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Exclude current post but keep the same posts-per_page amount
- wordpress custom fields loop
- How to show related post with category DESC (ASC) IDs of ID current post
- Avoid showing the same phrase in the loops
- Multiple loops on same category with different design
- Custom query pagination with php parameter as arg problem
- Multisite – Getting Meta query to select from wp_2 tables
- How to append the excerpt to the content in the single post page?
- Multiple Owl Carousels on the same page with navigation problem
- Pull A Single Post Prior To Running wp_query
- Highlight specific user with custom field value
- custom loop issue
- Secondary loop doesn’t work
- How to show the posts list into a static page? Problems to use the loop into a static page
- Limit the number of posts from a specific category on index.php
- Pagination problem with multiple loops on the same page
- Post thats in Two Categories, only want to display name for one
- Getting Custom Field value in WP_Query
- Loop display only 5 posts
- How do you get the count of posts in an archive page?
- WordPress objects class reference
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Customizing gallery shortcode in 3.5
- How do you add pages on a staging server, and then move them over to production
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- Theme Twenty Fifteen: Customize Color Scheme Customizer
- Display tags with a twist
- How to add another page in appearance tab of admin panel?
- WordPress change author email notify message?
- how to flush custom author rewrite rule
- Updating Widget options in custom install.php
- How to use WP_Query to display many posts?
- add JS to multiple plugin admin pages
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- Five posts from a category in footer
- Follow me for WordPress blogs (multi-authors)
- custom theme ,add media not showing images in media library
- Get Image from Media Library with the Title
- Order by empty custom field
- Allow a Widget to be used one time only?
- New WP_Query loop in admin causes problems
- Best way to allow overwriting images shipped with the plugin?
- Static Front Page settings – distinguish between Front page and Post page
- How to print Array values of custom Fields Meta?
- posts archive page – closing WP_Query loop correctly [closed]
- AJAX Breaking Offset Argument In WP Query
- Customizer JS API get value of customizer field
- Daylight Saving Time adjustment
- Hide content and functions from specific user roles
- meta_query with array as value with multiple arrays
- Translating (WooCommerce) placeholder text
- Search.php gets metadata from first post
- How to make the ‘request’ filter work?
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Can we set a redirection with dynamic content in url?
- How to remove (…) from the post tilte on homepage?
- How can I setup a development environment which auto refresh page when code have changed [closed]
- Trouble with custom login page
- I want to use a product thumbnail completely different than the product image
- How can I edit the WordPress menu link to allow fb: instead of http
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Change Dashboard menu position?
- Get site ID from attachment url?
- WP_Query & Duplicate entries
- duplicate featured image functionality in custom meta box
- How to automatically pull an information from a form field onto an other page?
- How to create a custom menu for specific user
- Move text from the side of image to below image [closed]
- Custom terms in custom category taxonomy
- WordPress Numeric Pagination with Query String [duplicate]
- Customize TinyMCE Buttons
- How to show featured post first, then separate loop for other posts
- Instead of Custom CSS Theme CSS is loading
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen
- How to display product variations on same row