Title: filtering the wrong query
Last modified: August 21, 2016

---

# filtering the wrong query

 *  [David Dean](https://wordpress.org/support/users/ddean/)
 * (@ddean)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/filtering-the-wrong-query/)
 * Hi Dinesh –
 * The form on your site is not accepting my post (probably too many function names
   🙂 ), so it’s going here.
 * The `tcp_add_post_types_in_category_and_tag_template` function has a series of
   checks for category and tag, but they are checking the page’s main query rather
   than the one that was passed. This is breaking sub-queries on category and tag
   pages.
 * To fix this, replace `is_category()` with `$query->is_category()` and `is_tag()`
   with `$query->is_tag()`
 * Looks like lots of people are running into issues caused by this bug. Restricting
   the filter to the main query as some have suggested will help but also limit 
   functionality. I believe the steps above provide a complete fix.
 * – David
 * [https://wordpress.org/plugins/add-tags-and-category-to-page/](https://wordpress.org/plugins/add-tags-and-category-to-page/)

The topic ‘filtering the wrong query’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/add-tags-and-category-to-page_f6fdf9.
   svg)
 * [Add Tags And Category To Page and Post Types](https://wordpress.org/plugins/add-tags-and-category-to-page/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/add-tags-and-category-to-page/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/add-tags-and-category-to-page/)
 * [Active Topics](https://wordpress.org/support/plugin/add-tags-and-category-to-page/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/add-tags-and-category-to-page/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/add-tags-and-category-to-page/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [David Dean](https://wordpress.org/support/users/ddean/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/filtering-the-wrong-query/)
 * Status: not resolved