Unfortunately no one answers my question so I will show my way to solve this problem.
I use public query vars with get_query_var and set_query_var functions to set widget__exclude variable across all queries.
Still not sure that it is the best way for this case but hope it helps somebody.
Related Posts:
- Prevent duplicate post from dynamic multiple loops
- WP_Query offset is returning post from prevois loop
- Prevent Duplicate Post Counted by Query
- Using a custom WP_Query with get_template_part loop
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_QUERY Get posts by category and similar name (Like)
- Using get_posts vs. WP_Query
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Is it possible to wrap Geo Location search around WP_Query?
- How to Access Global $multipage or Global $numpages outside the loop?
- What is an efficient way to query based on post_meta?
- Merging a complex query with post_rewind and splitting posts into two columns
- Pagination wont work with search results template [duplicate]
- Pagination Not working on Home Page with 2 Query
- WP_Query in a shortcode
- ‘posts_where’ filter not applying ‘WP_Query’ in `wp_ajax`
- Get all posts without tags
- Sort by meta key on archive page
- Retrieve or Query Pages by ID
- Searching through different categories on different pages code is not working
- how to get the id for a post from within a post and return post meta for it
- How to make this WP_Query run faster on a WordPress website?
- Order taxonomy terms in alphabetical order
- is_search was called incorrectly
- How do I sort posts with multiple pages
- Complex date range with WP_Query and BETWEEN
- Attachment changing page’s permalink – $post not resetting?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Make (post) query a clickable link
- How to set pagination to work with ‘/page/’?
- How to do meta_query for attachments?
- Most commented last 24h, week, month, year and all time – posts_where
- How can I filter by slug depending on language selection
- How to duplicate 5 posts out of WP_Query results?
- Ajax WP_Query reutrns no results on author.php
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Dynamic User Id
- get_post_meta slowing down my page load (in a plugin)
- use of 10 new WP_Query : loading too slow (with url) [closed]
- How to make a second query offset -2 from current post
- slow query – Search for Media Gallery
- How to not display tags with less than X posts
- WordPress has a list of reserved words, can I override them, to use one in a query string?
- Wp_query with 2 meta keys and array of meta values
- meta_query: check if number exists
- How to order WP_Query to group results?
- Search Page Returns Nothing
- Which meta_query and post_content blend is better in WP_Query, performance wise?
- WP Query causing timeout
- get term id from term name
- Problem with get_page_by_path() using with WP_Query
- Query where ANDing slug values not working
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- query post by author gender
- How to access $wp_query object from array of posts given by get_posts?
- Display all attached image of every post of custom post type and link to original post
- How do I add an item to the WP admin menu?
- Links in the_content not linked
- how do I write this wp_query select statement?
- Post incorrectly excluded when using “category__in”?
- How to search by slug and old slug in single API
- Reciving Error 404 blog/page/2/
- Categories In English version showing not canonical URL, instead shows query search result
- Multiple meta_query not returning rows
- show related articles in single.php template
- What code to use in an array to call the current sub-category?
- Query against multiple locations within single custom post type post
- Order by meta date with a thousanth of a second defaults to post order
- How to debug none working search query?
- Order by Date Custom Field
- WP_Query showing all posts, except from category X, unless it’s also in Y
- Show posts by category – category ID not working
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- Show All with Isotope
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- active link for most recent post on vertical tabs
- wp_get_attachment_image not to get the post_thumbnaill
- option select form always deleting the sql query
- WP_Query to show post from a category OR custom field – Not 100% answered
- Page displaying 1st post from a range of custom tax?
- Pagination in custom query in a category page
- WordPress WP_Query Array Custom search via taxonomies
- Add category and user name to recently updated post list
- Pagination in WP query with transient API
- How to do a loop inside a loop?
- Pagination not working in secondary query
- WP Paginate not working properly
- How to get child pages and add unique class only to active page?
- Main loop querying current template’s info only in custom category archive pages, not my posts
- How can I display sticky posts at first in wp_query?
- Incorrect taxonomy ID assigned to post with custom query
- Splitting query results, on the frontend, into separate sections based on meta value without multiple loops?
- How WP determines archive page vs single page?
- Sort wp_query of two post types using meta datefield for one and date for the other – possible?
- wp_query returns all posts even with post__in and posts_per_page
- Get related posts from tag otherwise from category (Ajax Load More plugin)