The post__not_in arg should work for you:
$args = array(
'numberposts' => 5,
'offset' => 0,
'category' => 7,
'post__not_in' => array( $post->ID )
);
$myposts2 = get_posts($args);
Related Posts:
- Skipping first 3 posts in wp query
- Exclude ALL posts from sub categories
- Exclude posts with specific meta_value while sorting by a separate meta_value
- Filter Posts by Excluding Categories
- How to set post expiration date and time and move the page to archive after expiration [closed]
- how to get posts ids inside pre_get_posts filter?
- Exclude the first ‘n’ number of posts of a tag from home page?
- Excluding posts not working
- Loop doesn’t exclude the specified category in home page
- How to exclude posts that already appear in the main loop, from the category loop
- How to get post with slug and exclude categories
- Exclude post category in a blog page
- Use posts_where to exclude posts ids from wp_query
- Conditionally exclude post from specific category on home page sidebar?
- Excluding category from post navigation in WordPress?
- Exclude a ‘portfolio’ custom category?
- Changing the post date and time with function
- Modify ‘Read more’ link adding a new class
- Modifying admin sidebar contents to show pending posts indicator
- Add “Post Options” for new wordpress post
- Are all ID’s used unique?
- How to lock content?
- Getting an alphabetic post list with two letters onclick on letter
- How do I change the gallery that is inserted in the post?
- Get the author of the latest revision
- Show posts in category x and y from the 6th most recent post onwards
- Use template of parent category for single post sub-categories
- loop not displaying posts on custom template page
- get post id in while loops outputting page id
- Embed WordPress Admin in an iframe
- ping_status in JSON REST API
- WordPress 4.4 release produce blank white images when sharing a post on Facebook etc
- How can i do something after head like adding a hook for after head but before post
- How to get the post’s parent ID?
- How can I write comments/hidden text in a post?
- Random post category URL
- Save re-arranged draggable post items to wordpress database
- custom post scheduler for drafts
- How to make a price range slider from get_post_meta?
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Prevent Delete Attachment by URL or When Submit
- Non-existant URL redirects to existant one
- pagination for single post by category
- Post page to display specific category
- Calling Different Custom Post Timestamps in a table
- Increase 10 post limit per page
- Hooking into the post editing screen for an existing page only
- Shortcodes on my website stops working after theme update [closed]
- How do I retrieve a users’ last 5 posts?
- Show posts by author of membership level (Paid Membership Pro)
- How can you display all sibling categories to a post?
- New Gmail email to a WordPress new post? [closed]
- How to show show the Second page title in the page
- How to calculate the average of a post meta value(Numeric) of a specific author
- Published content not displaying, getting not found message
- retrieve the oldest post id
- How can I remove the first two words and shorten get_the_title()
- Lock post editing to one user at a time – wp_check_post_lock
- where to download bb-ratings plugin for wordpress?
- how to hide empty fields of post category description?
- how to add updated_by column to posts admin panel?
- If no posts exist for current day and month, show the next available day of posts
- How can I get rid of the automatically generating tags?
- Get latest post from categories
- Simple Custom Metabox Not Saving
- Access last visit time to a post
- Loop not showing first post
- How to show a featured image inside a post in only 1 single category
- Custom Post Type Single Loop Outputting Wrong Post
- Geting error in post and category [closed]
- WordPress Post Deletion Issue
- How to remove the ManageBlocksMenuItem in the ToolsMoreMenuGroup in the Gutenberg Editor?
- Target only single product page
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How can get the last post date of the user?
- How to convert attachment pages to Posts?
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Create/Set Category as Title of Post
- Blocked posts in network tab
- how can i fix my display post in my index.php
- Ajax post doesnt call succes after got the response
- Adding a ‘section’ to the backend menu
- Get 5 most recent categories
- List of authors posts minus very latest
- Add category attribute to custom recent post shortcode
- How can I show my post under a certain content name?
- How Can I Limit Users to Post Creation For My Frontend Theme?
- how to create add-able metaboxes in wordpress post edit screen?
- How to display only one post on first category page and rest on next pages?
- Show Custom Post From Logged In Author
- How to display a paginated list of posts from one category on a page? [duplicate]
- Is there a way to separate wordpress titles from their posts?
- custom sort posts in archive/taxanomy page
- Trying to create shortcode listing custom posts, but formating not being included
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- remove description in colum title post
- Show some texts in posts belonging to Specific category
- Undefined Function Fatal Error with Shortcode [closed]
- How to sort posts alphabetically based on a specific parent category