Of course! I just had to set the $accepted_args
parameter of add_filter()
to 2. Like so:
add_filter('posts_join', 'my_join', 10, 2);
function my_join($join, &$query) { echo $query->is_main_query() ? 'y' : 'n'; return $join; }
Related Posts:
- How to modify posts_where filter only for the search query
- Where is the proper place to add a filter for pre_get_table_charset?
- Get .subsubsub count of post per status queried using pre_get_posts
- Get Posts updated or published within the last x hours
- Filter authors on meta value
- Custom SQL query slows down when using multiple OR … LIKE … in posts_where filter
- Customising the default wordpress search functionality
- Remove the post_content search from WHERE clause (and CONCAT sql function)
- using posts_where for meta data on pre_get_posts
- Adding an orderby filter, casting postmeta with multiple keys
- How to create a list of terms who’s posts also have a predefined external term?
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How can I modify the WordPress default widget output?
- How to use update_{$meta_type}_metadata filter to modify meta value
- How to wrap an element around an iframe or embed in content automatically?
- Earliest hook to reliably get $post/$posts
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- Completely strip any hidden formatting when pasting into TinyMCE
- How to add filter to __() and _e()?
- Remove “Private” + “:” in title does not work
- Adding a class to the body_class function
- Change text of Description in Image Library
- Allowing non-latin characters in registration
- WordPress Rest filter for custom taxonomy gets applied to the admin area
- add class to internal links in content
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- Help debugging PHP filter for wordpress [closed]
- About Hooks and Filters
- How to always display a specific post from the search result first
- filter title from shortcode
- Add a Span Around a Product Title in WooCommerce [closed]
- How to filter into post meta data before saving
- Adding custom column to comments admin panel?
- Filter out some plugin action in wp head / wp_footer
- Filter Gutenberg Blocks Content
- How do I replace a render_callback function for a block?
- check if FILTER(“the_content”) is being executed in `the_post()`
- Change Password Strength Indicator names?
- Can the wp_filter object hold multiple values with the same key
- apply_filters/do_action tag characters limit
- When to call add_filter
- Limit RSS feed to previous calendar month
- How to stop wrapping comments in P tag
- How to modify core when there is no hook?
- Is this the proper way of switching the “Edit My Profile” link with my BuddyPress “Extended Profile” link?
- html tags in gettext hook get escaped
- How to remove action with slashes and arrows?
- Set default terms for new posts / CPTs
- Better extend a class or use add filter/action hooks?
- Adaptive product filters for WooCommerce
- Adding a Clone link to product attributes – post_row_actions() filter, or how to override a Class question
- wp_upload_bits Upload Specific Sizes Only
- Plugin options, presets and filters : can you help me improve my workflow?
- Why does adding a filter to ‘the_title’ break the server?
- Wrapping my head around add_filter
- Can i use multiple ‘the_content’ filters?
- Is it possible to put the add-filter()-hook into a function?
- How can I return shortcode output to the top of the content?
- separate categories with comma and srounded by single quote
- Filter for when the post is updated
- term_link filter gives less atributes
- Filter a pluggable function
- apply_filters(‘get_the_content’, $content) + Except
- Add mime types with plugin
- Filter media upload attachment meta
- Filter have_posts()/ the_post()
- Filter wp_redirect() to stop redirect under certain condition
- Filter get_page_by_path()
- How to add filter in custom rss feed
- Echo string in admin panel footer beside version no
- How to change default text for specific post type
- Add PHP code after title in single post pages?
- How to stop the deduction in “wp_term_taxonomy” count, when the post is deleted?
- How To Get Search Term and Use in Function
- How to pass a variable between filter/action functions?
- Filter the title to only affect the_title() template function
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Adding link options in insert/edit link dialog window
- how to unescape wordpress output
- How can I limit access to uploaded media depending on the logged in user’s user role?
- Database & Post Search
- login_url filter creates permanent wp-admin -> wp-login redirection loop
- How can I filter same content in page
- How can I change the button text of a custom widget?
- WordPress Tag Cloud Filter Prevents Widget HTML from loading
- Using add_filters() , apply_filter(), add_action() and do_action() in extending a plugin
- the_content filter not working when Jetpack activated. Any idea?
- Adding Filter | Page Title | Template | Why the_title affecting on menu?
- gettext filter does nothing
- Code restricted to dashboard, running unexpectedly in the frontend (pre_get_post and admin-ajax.php)
- Why none of xmlrpc filters work
- How to use the filter ‘widget_text’ to a particular text widget with id
- Filter for wp_embed_handler_youtube not working
- Hook into ‘when user logs in’ [persistent login]
- Filter on widget-title does not work with custom links
- How to reset/remove added filters ‘posts_join’ and ‘posts_orderby’ after the loop is completed?
- Conditionally including JS based on whether ACF field is set [closed]
- Hooking/Filtering theme name to add theme directory
- How to use filter in this situation, can not modify the structure using filter