Use the parameter 'post__not_in'
to exclude post IDs:
$posts = new WP_Query(
array (
'post__not_in' => array(get_the_ID()) // exclude current post ID
)
);
Related Posts:
- How to get Images included in Post
- Accessing the post content with WP_Query
- How do I use inline SVG in WordPress
- Is it possible to add a first and latest posts link?
- Setting post meta data to random value during post status transition / on publish
- Add link on the top menu of the post table?
- Get the object ID by URL
- Add a special filter link to All Posts in admin
- wp_list_categories link to first post of category instead of calling taxonomy template
- Alternate custom content in the loop
- Custom Post Status Posts viewable to the public
- Add an image box besides featured image?
- Use Cron to modify posts via sql
- Pull posts from another wordpress install on same server
- How only display all post related to category
- Using Custom Posts with Metaboxes and Drop-downs
- Create pretty permalink for a post knowing the permalink structure
- Add category to all post by using sql query?
- How to change the title url on the edit post screen?
- Only display posts after current date
- What differences are there between a Privately Published post and a Draft post?
- Update post status from “publish” to “trash” for half of posts
- jQuery inluclude still seems ncessary for script to work within post
- White Blank Page when Updating and Publishing Page/Post
- Can I create a not clickable post?
- What is the standard featured image size?
- WP_Query Authors OR Categories
- get_the_content_feed with paginated posts
- Pass data between pages
- How to create large page
- How to get rid of shortcodes in post content once and for all
- Why is querying posts messing up my pages?
- How can I find out what items a user has purchased? [closed]
- Print all the tags from a custom post type Please
- WordPress Loop – Next 3 Posts
- How to attach an image to a post through Java
- How to do set post permalinks using 6 digit random unique function?
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- Prevent scheduled post being published if date/time is past current date/time
- Set Default Category to Username
- Issue where WP Featured Image will not display
- transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]
- All Posts admin screen – show time underneath the ‘Date’?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How to save meta checkbox WordPress
- Sidebar show posts by current category also in single post
- Category Redirects to homepage [closed]
- SQL Command for restoring trashed comments
- Displaying post excerpt using wpdb query
- Loop don’t work within single.php page
- How to display Changing post link for 24 hours in x category
- Upload attachment from external site
- WordPress.com post editor replacement
- Custom permalink for each post
- Related Posts: Changing Function For Posts Per Page
- load more posts by category
- Import custom database into wp and keep the post id
- Retrieve a specific post’s featured image and show on a different page
- How to split authors?
- Display Related Posts by Category in Random
- WordPress wp_editor to post and edit
- How to display Post title By ID and its Thumb Contents
- Jumbled writing under a post
- Is there a way to define the $post var outside the loop?
- How do I keep raw HTML in my RSS feed and not lose my paragraph breaks?
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Blog Posts – Scroll to view more
- After updating to 5.9, when the posts page is loaded in the browser it uses wp-includes/template-canvas.php?
- Show only posts with titles/permalinks that do not contain certain words
- Featured Images most often doesnt appear
- index.php not getting blog posts anymore
- Why is WordPress showing a blank excerpt for just one of my posts?
- Is there a way to know when a page has been updated and do some action only once?
- Mysql update menu_order problem
- Reuse old post ID for new post after deleting post
- Contact Form 7 Shortcode not recognized inside another shortcode
- WordPress Pods Custom Post Type – separate Media Upload folder for each custom Post Types
- Put page on Archived statut after end of publication date
- Blog Post slider not working
- Display new posts categories in separated divs
- Point to a page when there is no results
- Remove All in One Seo from Posts for Contributors
- Add row after three columns
- update post category in a new table on frequent change of category
- Edit Posts Page but not category specific pages?
- Show posts between two Custom Fields date
- How to display an icon when a new post is published and then remove it when a specific time past?
- How can add metabox for post of specific category before save post and after save post [duplicate]
- Posts page template: How can I edit the markup for this?
- Pagination working locally but not on live site
- How to store post rating system data post independent?
- Displaying different posts Via wp_list_categories()
- get_post_meta property of non object
- Which hooks are essential for post templates?
- Should new posts already have tags?
- Post UI Tabs plugin double fade effect
- Error 404 blog/page/2/
- WordPress limit post that subscriber can create
- Is there any point to using wp_unique_post_slug?