Most of the things you can do with a query are described in the Codex page for WP_Query
You need to use the ‘post__not_in’ parameter eg:
$args = array(
'post__not_in' => array('34','54'), // post ids
'post_type' => 'page'
);`
Related Posts:
- posts_per_page no limit
- Get the ID of the latest post
- the_author() returns empty string
- How to return results of a get_posts() in explicitly defined order
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- How to display posts by current user/author in a custom page template?
- How to order posts by descending comment count on taxonomy page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Sort X categories by last update and show image
- Pagination on archive.php page
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- Query only Posts from Both of Two Category?
- Schedule Sticky Posts
- Insert custom div between posts
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- ascending order custom post type
- Problem with single-page for my custom post
- How to Display Post View Count
- How to make the list of post and load on same page with sub-pages [closed]
- How to get 4 Posts after the 5 most recent ones
- post_status => publish not working
- Can I set and show “important” post in my blog?
- How to fetch all posts in a category that were published between two given dates?
- Exclude posts from homepage having a specified tag
- get_meta_data within a loop
- Order posts using a custom array
- how to exclude “featured” posts from the main loop?
- Show Only Posts Owned By Logged In User + my post
- pass query string on url to filter media
- Order posts by condition
- Co-authors plus problems with query_post
- Error sending array of inputs
- Custom MySQL Query with logic
- Search breaks when querying main loop for category
- trouble with query to fetch next and previous posts
- How to exclude latest x posts from a paginated query?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Adding conditional content to single post-type template
- Query posts by meta_key whose value is an array
- How to make multiple sections in home pulling posts category wise?
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Proper syntax to add boolean in array()
- Conditionals if tags exist?
- Counting Search results, and displaying the offset per page
- Posts – display all posts except a post by an ID
- why the same code got different results when using query_posts in functions.php and index.php
- How to only publish posts with image in it
- Currently using a query_posts() in my theme – want to use a request filter in stead
- Breadcrumbs stop working on a specific template file
- WP_Query: Show 10 posts in date order, first three random
- Random posts that always include a particular post?
- Order for custom field after the loop
- List all posts in taxonomy term
- Custom post query error
- Saving a post ID to use in a form elsewhere on website
- Multiple instances of query_posts
- Different layout based on post amount?
- If Query Post Returns 1 Post
- Change content off every sixth element
- How to check a list or feed of all posts under a category and tag?
- Keeping get_posts’ offset and is_paged() synchronized
- odd behaviours from template tags
- query_posts thumbnail condition
- Show posts from specific roles
- How to add an “or” instead of and “and” (&) in a WordPress query?
- Instead of 4 loops, how can I do it better?
- How to get any type posts include attachments by ids?
- Create a Loop with Posts Ordered by Most Recent Comments
- get posts, run a custom query, and join the results
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- How to display particular categorie’s post which associated to specific user?
- Specifying image size used in template the_content
- Use WP pagination functions on a custom page template
- allow user to edit posts made by others users based on the user role
- How to correctly escape data
- Sort Events by Venue Title – Sort Post set by related post ids
- Get posts by category or author
- Order posts by ACF checkbox
- How to pass multiple checkbox values to wordpress query?
- Post per page not working
- Show previous month’s posts
- why is pre_get_posts not working
- query_posts result differs from wp_query request result
- How to get all post titles starting with numbers and symbols?
- How to inject a post within a loop
- How to get alphabetic listing x other posts, based on first letter post?
- Query posts based on parents attribute
- orderby not working for query_posts using array of IDs
- Collect posts from last 48 hours
- How to go to tag archives using a form
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- How to modify this function to exclude also the post belonging to a specific category?
- Sort posts with multiple meta_keys
- Create “archives by year and week” by category template
- query_posts different amount of posts per page [duplicate]
- Do I need to create a multisite for querying posts from multiple WordPress sites?