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
- How to make WP_Query faster when getting a post from one year ago?
- Pausing and Resuming WP_Query results
- How to do set post permalinks using 6 digit random unique function?
- Select only post id and meta value with WP_Query
- WordPress custom Query for Posts in Category display posts multiple times
- Lost draft under all posts and drafts
- Random ajax load only works with posts_per_page set to -1
- Prioritize posts in query by meta keys?
- MySql query to get posts with all meta and terms
- How to : pagination in 3 different custom loops on the same page
- get query() without post content?
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- How can I setup a relationship using categories in WordPress?
- Query posts and return XML
- how to change the number of posts returned in a specific loop without making it global?
- Query Posts With Over 1000 Views
- Custom order for Mysql array
- How to order posts by meta_value and title
- How i can limit period of post publication?
- wp_query random post
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Adding a blog archive with pagination using WP_Query
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- How to get Tags with specific post id
- How to setup a query to output posts by groups of five?
- Remove a shortcode from all WordPress posts
- Order posts alphabetically: how to set order=asc in mysql query?
- how can i change WP main archives loop to sort by name or title
- Using wp_list_pages() after calling query_posts()
- What do these phpMyAdmin errors mean on my WordPress databaes?
- how to get post order by post id wp_query?
- Possible to alternate between two loops
- Exclude current custom post on single post
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- Dynamically switch template on click
- How to get posts and comments amount per hour, per year and per month?
- Get all custom post types excepted some…
- Get all comments of author’s posts
- How to display all posts divided/ordered by post date? [closed]
- First x post with another template then the others
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Delete all drafts?
- Show post content and title in diferent divs using WP_Query using a loop
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- Why are my paginated posts always returning the same results?
- Ignore latest two posts
- Is it possible to use WP_Query to only pull posts with attachments?
- Wrap every month posts in div
- Show posts by author of membership level (Paid Membership Pro)
- Counter is skipping post when I still want it visible [closed]