I don’t really understand what you’re trying to do, so here goes nothing:
There are a lot of hooks within WP_Query. Most of them pass the current instance as one of the arguments. So, here’s how you could check for a “custom query”:
function check_wp_query( $posts, $wp_query ) {
if ( $wp_query->get('my_arg') ) {
// it's a custom query
}
return $posts;
}
add_filter( 'the_posts', 'check_wp_query', 10, 2 );
The trick is that each custom query has to be identifiable by at least one of it’s query vars.
Related Posts:
- Prevent pre_get_posts filter on specific post type
- How to use a custom post type as front page?
- Search multiple custom fields by using meta_query
- Custom Taxonomy with Custom Post Type Finds No Posts
- Redirect after deleting post and keep track of pagination
- Querying Posts by Taxonomy From Alternate Network Site
- Query by 2 values of a repeater ACF field
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Include both default and Custom Post Type in query modified inside pre_get_posts
- WP Query group/order by category name
- Remove POST_TYPE from custom post type permalink
- Custom Taxonomy and tax_query Issue?
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- Having trouble with custom date field for CPT query (WordPress)
- Impossible to get Attachments Outside WordPress?
- WP_Query search posts by custom post type and custom taxonomy
- Calculating Bayesian average for custom post type
- Conditional to modify query results
- Custom Post Type | Fatal Error on register_post_type()
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Show Two custom Post type and their posts on category page
- Querying Term Posts in Loop
- Use get_post_types to query only custom posts types
- WordPress Orderby Numeric Value Not Working
- Get rewrite slug of custom post type in template
- How to customize a permalink (URL) structure?
- Plugin: register custom post types, child ready and performance best practices
- convert custom query to wp_query
- Search / Filter posts on Title/Content OR Tags
- Meta query for custom post type ignored in main query
- How do I move/order posts with a tag to the end?
- Orderby CPT custom fields not working
- creat filter with wp_query
- WP_Query custom post type query not showing the exact post type
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- First custom field value (out of several) displayed twice after query
- Prioritize posts in query by meta keys?
- WP_Query orderby and tax_query
- Different Ways to Query Custom Post Types?
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- Redirect to another page using contact form 7? [closed]
- Showing specific post in order of array wp_query
- Detect inside a custom query the kind of post type to assign custom classes
- Number of posts in the archive
- WP_Query() with custom post type and taxonomy — get all terms?
- How to insert data into meta box from another plugin?
- Returning a custom content types with meta values
- Display custom post type for specific user
- Create query for both custom post type and category
- Convert Custom Table Data Based Plugin To Be Searchable
- Query custom posts from custom taxonomy
- filter the_content, custom post type, and wp_query
- Related “custom post type” using “custom taxonomy”
- Wp Meta Query does not work while simple Query Works
- Custom Form / Search with Custom Post Type Data
- Get next and prev item from custom WP_Query and Custom Post Type
- Change search query in wordpress custom post type
- WP Query from two Custom Post type fields as statement
- WP Query: If field X is empty, show posts based on field Y
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- custom post type and user post count shortcode
- How select query is generated in a Custom Post Type?
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- post type => ‘any’ not applied my custom queries
- Linking posts together with Advanced Custom Fields “both ways”
- Multiple WordPress Sites, Same Database but Filtered Content
- Error in WP Query. If variable is empty it is displaying previous post value
- Get posts of an specific term of a custom taxonomy
- Conditional posts in WP_query for search
- Custom post type not being pulled in widget
- Query Pulling the same post twice
- Registering an optional custom post type from a plugin
- WP_Query for CPT with filter by another WP_Query
- Is it possible to add query parameters on the archive page?
- How do I get a nested query to only display content that the main query outputed
- Add category slug as class attribute in a link array
- Query child posts on parents single.php?
- Query Posts From Multiple Post Types
- Add Excerpt On Quicksand Plugin
- WordPress can only query up to 766
- Multiple Block Quotes without using HTML
- How to apply order on custom taxonomy and custom meta key on custom post type
- custom post-type query just returns two posts
- Filter Custom post type by another Custom post type
- Create a list of months based posts
- Set a Custom Post Type as a Homepage
- Sort CPT by taxonomy AND THEN by custom field
- Load posts via AJAX without draft status
- Add custom post type as submenu [closed]
- Building Link List for Custom Tax
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- is therer any wordpress function to retrieve a specific html element from post content
- WP Query – Can’t get posts with specific taxonomy