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
- Advanced Custom Fields in WP_Query: Href Returning Empty
- Is there a way to set the value and text for Select/Radio/Checkbox using More Fields?
- List authors with the last post title and order by last post date
- Track usernames with piwik [closed]
- Custom Log In Screen – Disable password recovery [duplicate]
- Custom loops, sticky posts, and pagination nightmare
- Can I add/replace the WordPress image in the Dashboard
- How to make a second query offset -2 from current post
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- WordPress Custom File Permalink
- Post thumbnails not working in my new install of WP 3.1 with Twenty Ten theme
- WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues
- Save title as custom field on custom post type
- Custom Role with Own Page Edit Capability
- WP Group posts by year(desc) > month(desc) > date(asc)
- Qtranslate + Woocommerce (multiple tinymce) [closed]
- pagination not working for category.php (custom post types in categories)
- Running main loop 2 times with conditional statement
- “An automated WordPress update has failed to complete – please attempt the update again now”– But there is no .maintenance file
- wp_query random post
- CSS Customizations for certain page
- Blog page problems
- Only display post if published in last 24 hours?
- Split wordpress loop to multiple layouts
- How do I redirect a post url to a custom url?
- List top 5 authors with most posts
- How can I create a permalink with two categories, with the order based on the parent category?
- How can I have a common background color across multiple WordPress blocks?
- Need to convert string of term ids into comma separated integers for use in an arguments array
- How do I add a promotional message to my posts?
- Changing settings of WooCommerce
- Redirect to another page using contact form 7? [closed]
- WPML Plugin Not displaying multilingual Menus
- What WordPress Hook Is Used Before Signup Data is Saved?
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- What requirements for ACF custom fields key and name properties?
- How do I remove a customiser option from a parent theme in a child theme?
- How to locate where an element is generated?
- Is it possible to change the structure of the HTML generated by the_content()? If yes, how? If not, is there a workaround?
- How to recover permanently deleted blog posts?
- Create “alternative/zebra” boxes in the content area?
- Keep Title and Description always
- Custom CSS at Appearance > Edit CSS is missing after update [closed]
- How do I automate multiple category loops?
- Theme compression/ minifying or W3 Total Cache – which should I use? [closed]
- WordPress | Date not always appear [duplicate]
- Wrapping x posts in html without leaving empty html
- How to remove all the items under “Personal Options” on user profile page?
- the_post_thumbnail() returns nothing even though has_post_thumbnail() returns true
- orderby in query_posts
- What is the best way to move a single site from one MS installation to another? [duplicate]
- Multi-site User Sessions
- Extend WordPress Core Classes in OOP Theme?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- WP Query post__in not returning correct results
- how to display a specific wordpress menu?
- Custom taxonomy.php not working