How can I apply pre_get_posts to a custom query?
For example, if I have:
$custom_query = new WP_Query(...)
//code here
How can I apply the pre_get_posts for this $custom_query?
|
How can I apply For example, if I have:
How can I apply the |
||||
|
|
|
For some use cases, couldn't you use For example: say you've got a custom query for a
Granted, this will target every such |
|||
|
|
pre_get_posts fires for every post query.There is really no reason to apply it to a specific custom query. If you don't want it to be applied to your custom query you need to make sure you are checking for is_main_query(). |
|||||||||||||
|