- This topic has 1 reply, 2 voices, and was last updated 5 years, 8 months ago by .
Viewing 2 posts – 1 through 2 (of 2 total)
Viewing 2 posts – 1 through 2 (of 2 total)
Posted
by
Forums › Forums › Search & Filter Pro › Filter current post
I was wondering if it’s possible to exclude the current post from the results. User case:
I have Webinars as a custom post type and I want to show the next 2 upcoming webinars (based on a advanced custom fields date input field) on each webinar post page. This works totally fine now via the plugin except for one thing; When I am on the page of one of the first two already, I want to exclude the current post and show the 3rd upcoming webinar.
So simply what I need is to exclude the current post ID from the results. Is there I way of doing this? I have looked around on the internet for solutions but cannot find any.
Thank you in advance
You would need to do some coding, using this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
You would need to build some PHP logic to detect what page ID you are on, and then add that as an exclude. See post__not_in here:
https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters
You might find some snippets in our forums with this search:
https://support.searchandfilter.com/forums/search/post__not_in/