Don’t forget that when you are adding a filter it will stay there for all subsequent request.
I would suggest you remove the closure and do something like this:
function x_example( $input ) {
remove_filter( 'posts_where', 'x_example' );
return $input;
}
add_filter( 'posts_where', 'x_example' );
You will have to do the same thing for the posts_join filter.
Update
As pointed by @bonger you could also keep the closure using the following method:
$closure = function( $input ) use ( &$closure ) {
remove_filter( 'posts_where', $closure );
return $input;
};
add_filter( 'posts_where', $closure );
Related Posts:
- How to limit the number of posts that WP_Query gets?
- Should we trust the post globals?
- Random sort within an already sorted query
- How to know if get_posts() failed?
- WordPress Number of Posts Not Changing With posts_per_page
- How to add posts to wp_query result?
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Query All users that has post
- Search query – exact post title match
- posts_per_page doesnt work
- How to start with post number x?
- Exclude posts with empty post_content in wp_query
- Only display a certain number of posts, dependent on how many posts there are available in a query
- Improving WP_Query for performance when random posts are ordered
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Get Posts that are in the current month or later
- Get user categories with most posts in it
- Exclude the first ‘n’ number of posts of a tag from home page?
- posts_per_page option limits the number of Gallery items
- List authors with the last post title and order by last post date
- Why Query is returning empty array?
- meta_value timestamp older than now
- Do not show children of a category
- Query for first 3 posts to change the look and feel
- Why posts array is empty?
- How to give classname to post if post has no content?
- Queries take 120+ seconds on my large WordPress site
- Exclude some posts from displaying in wp_query based on some condition
- Related Posts function not working
- How to retrieve certain number of images from a wordpress post?
- How to convert query sql to shortcode in wordpress?
- get last post’s link with SQL query
- How Can I Always Display A Particular Post First Using WP_Query?
- Return records between two meta datetimes saved as strings
- WP query taxonomy optimization
- WordPress Query – Display 5 posts (same post type), each from a given tag
- Query to fetch custom taxonomy along with post title
- filter posts based on menu_order
- Show 5 posts and than 3 posts offset with pagination
- wp query custom orderby not custom field
- Sort / Filter Queries
- Advanced Post Display/Pagination/Ordering
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Displaying Results From Custom Taxonomy Query
- WP_Query retrieve custom posts but not the post showing
- Wp_query WooCommerce products
- SQL Query for getting all posts in their latest revised state
- Querying post from a multisite network
- Show related posts by category but ignore one category
- post__in for get_posts with a dynamic array
- Duplicate posts
- Post content being duplicated by the_content();
- How to add padding between posts
- Add few specific post ids to wp_query
- WP_Query posts_per_page ignored
- how to get posts ids inside pre_get_posts filter?
- How do I use WP_Query to get a range of posts with custom fields that have numbers with letters in them?
- recent posts for different categories
- Change post order random through out the entire WordPress
- Setup a custom dynamic post
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- wp_posts table: safely remove unused columns to save database storage
- Using wp_list_pages() after calling query_posts()
- Counter is skipping post when I still want it visible [closed]
- Every second post different class in blog view
- How to get all post_parents of a post?
- Can’t understand why sometimes a [caption] field appears
- Run query_posts if SESSION is empty?
- Why in my query is display two title?
- wp_query with ajax
- Use posts_where to exclude posts ids from wp_query
- Why does WordPress search returns same number of results for every search query?
- Sidebar limiting to 10 posts?
- Adjust the order for returned posts
- Override WordPress core post-template.php block template
- how to add tags to post in the Loop?
- Change Old WordPress Post Date Year
- Display/Filter post using if else statement
- Search results for ACF data
- Query prints posts without specific categories
- Bulk Post update_post_meta
- Query doesn’t display text data with apostrophes
- Loop through all posts showing duplicates
- WordPress text field in array problem
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Get query result according to merged array
- Display the latest post from some selected authors
- How to show the posts list into a static page? Problems to use the loop into a static page
- SQL query to remove first image in all posts
- Query Posts From Multiple Post Types
- Multiple loops on a Search result page?
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- Make division in post_query?
- Display one post randomly from category on home page
- How do I show the post title if an advanced custom field hasn’t been used?
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)
- WP_Query post_tilte search in posts table