This code removes the current post displayed on any home archive pages from the recent posts widget.
Here’s an example:
The above screenshot shows 3 posts on the 1st page of the home page archives which do not display in the recent posts widget located in the primary sidebar to the right of the image.
When you go to the 2nd page of the home page archives, you also find any posts on that page don’t display in the recent posts widget however the posts from the 1st page and other pages do as seen here:
The following code works with any widget that includes the
WP_Query class or classes which enable you to filter query arguments like
WP_Comment_Query as well as functions like
Get Full Access & Support
You need to pay to fully access this tutorial.
Enjoy unlimited access & coding support by registering.
Note: If you’re using the Genesis theme framework, this functionality is already built into the Genesis featured posts plugin.