Title: Bug report: bad code in lib/query
Last modified: August 21, 2016

---

# Bug report: bad code in lib/query

 *  Resolved [Frumph](https://wordpress.org/support/users/frumph/)
 * (@frumph)
 * [12 years ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/)
 * file: lib/tribe-event-query.class.php
 * Bad code:
 *     ```
       // include events in search results
       			if ( $query->is_search && $query->get( 'post_type' ) == '' ) {
       				$query->set( 'post_type', 'any' );
       			}
       ```
   
 * the $query->set ‘any’ is not applicable in all instances where post_type == ”
   especially when other things are adding to it which results in regular ‘post’
   post type is not being found, commenting out this code makes them work again 
   for everyone else…
 * Using this in the register_taxonomy *should* be all you need instead of that.
   `'
   query_var' => true`
 * [https://wordpress.org/plugins/the-events-calendar/](https://wordpress.org/plugins/the-events-calendar/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Brook](https://wordpress.org/support/users/brook-tribe/)
 * (@brook-tribe)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908095)
 * Howdy Frumph,
 * Thank you for taking the time to document this! I will pass it along to our devs
   and they can review implementing it.
 * While I can not speak to these three lines, I know that we have found plenty 
   of times where doing all you “should” need to do means that you end up conflicting
   with some major themes or plugins. So, we have to find work arounds. It is possible
   that this code is just such a work around.
 * Thanks again, we really appreciate assistance in polishing off The Events Calendar.
 * – Brook
 *  [Brook](https://wordpress.org/support/users/brook-tribe/)
 * (@brook-tribe)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908134)
 * Hello again Frumph,
 * We have looked into this a bit further. We definitely feel like setting the post_type
   to any is not a perfect solution, and are interested in changing that to be more
   specific. However, your proposed solution will unfortunately not work for the
   variety of environments and situations our plugin is used in.
 * Would you mind letting us know what specific problem are you facing? Do you have
   other custom post_types that you wanted excluded from search results? Is that
   how you discovered this bug? If we have specifics then we can better understand
   if our solution is going to work for people in your circumstance. And if anyone
   else comes across this and has found it to be a difficulty, please chime in about
   what your are trying to do and why this affects it. Thanks!
 * – Brook
 *  Thread Starter [Frumph](https://wordpress.org/support/users/frumph/)
 * (@frumph)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908135)
 * The way you should do it, is get the the array of post_type and ADD yours to 
   it, not replace it – don’t set it to ‘any’; putting any nulls out any other and
   all other custom post types that are associated
 * The problem is that when something is ” it really isn’t ” it’s reading off the
   base of possible post types to search from from internal values; changing that
   negates those
 *  [Brook](https://wordpress.org/support/users/brook-tribe/)
 * (@brook-tribe)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908141)
 * > The way you should do it, is get the the array of post_type and ADD yours to
   it, not replace it – don’t set it to ‘any’; putting any nulls out any other and
   all other custom post types that are associated
 * Agreed 100%. That is what we are looking into doing. I appreciate your feedback.
 * > The problem is that when something is ” it really isn’t ” it’s reading off 
   the base of possible post types to search from from internal values; changing
   that negates those
 * I am not sure I understand this. If you are basically explaining that in setting
   the post_type to any we are going to include post_types that are not supposed
   to be included, then again we completely agree. I am glad you pointed this out.
   We can now find a solution for a future version. Thanks!
 * – Brook
 *  Plugin Contributor [leahkoerper](https://wordpress.org/support/users/leahkoerper/)
 * (@leahkoerper)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908149)
 * Hi there,
 * I just wanted to update you here. We were not able to fix this issue in time 
   for our upcoming release (3.6). However, it is still very much a priority and
   we plan to work on it for a future maintenance release. We will keep you posted
   on our progress. Thank you for your patience and support!
 * Best,
    Leah
 *  Plugin Contributor [leahkoerper](https://wordpress.org/support/users/leahkoerper/)
 * (@leahkoerper)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908188)
 * Hi there,
 * I just wanted to let you know that we were able to work on this issue for our
   upcoming 3.8 release. Keep an eye out on your site for an update announcement!
   If you update and are still seeing this problem, please post a new thread so 
   we can check it out. Thank you for your patience while we got this fix in place.
 * Best,
    Leah and the team at Modern Tribe

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Bug report: bad code in lib/query’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [leahkoerper](https://wordpress.org/support/users/leahkoerper/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/bug-report-bad-code-in-libquery/#post-4908188)
 * Status: resolved