Title: exclude certain query string
Last modified: January 12, 2020

---

# exclude certain query string

 *  Resolved [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * (@fkoomek)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/exclude-certain-query-string/)
 * Hello.
    I am using the basic caching method and have caching Query strings option
   enabled. Now, I would like to exclude a certain query string (Search results)
   from caching. The URL syntax is: [https://www.liberlapidum.com/cs/?s=emerald&post_type=product](https://www.liberlapidum.com/cs/?s=emerald&post_type=product)
   where the emerald is an example of a searched word. I tried to write down to “
   Never cache the following pages:” box things like: /?s= or /?s=*/ But this always
   excludes completely all query strings. How do I exclude only search results? 
   Thank you.
    -  This topic was modified 6 years, 5 months ago by [fkoomek](https://wordpress.org/support/users/fkoomek/).

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

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/exclude-certain-query-string/#post-12318913)
 * Hello [@fkoomek](https://wordpress.org/support/users/fkoomek/)
 * Thank you for your inquiry and I am happy to assist you with this.
    There is 
   no option to exclude specific queries from Page Cache. You should disable “Cache
   URIs with query string variables” add the page URL to the “Accepted query strings”
   field. Thank you!
 *  Thread Starter [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * (@fkoomek)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/exclude-certain-query-string/#post-12320754)
 * Thank you. I solved it by disabling W3 Total cache when the query string is /?
   =.
    So I wrote to mu-plugins
 * add_filter(‘option_active_plugins’, ‘lg_disable_plugin’);
 * function lg_disable_plugin($plugins)
    { if (strpos($_SERVER[‘REQUEST_URI’], ‘/?
   s=’) !== false) { $key = array_search(‘w3-total-cache/w3-total-cache.php’, $plugins);
   if (false !== $key) unset($plugins[$key]); } return $plugins; }

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

The topic ‘exclude certain query string’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/exclude-certain-query-string/#post-12320754)
 * Status: resolved