how to exclude URLs with specific query strings

[ad_1]

Hello there,

hoping you may be able to help.

Our shop page can be filtered by different parameters
format (an attribute)
price (min / max)
artist_involved (a custom taxonomy)

The queries result in URL strings such as

I would like sg optimizer not to page-cache any URL containing any the following query strings (no page caching of the URL whether only one or multiple of these strings are included in the URL, whatever the order).

min_price
max_price
artist_involved_filter (way more than 100 involved artists)

so ;
should be cached, but
so ;
should not

(Please note cd, vinyl are two of several possible formats; adam-rudoph is one of hundreds of involved artists : I would like exclusion rules to be of the form ‘=*’, covering all artists or formats, or prices for that matter).

I attempted two solutions, unsuccesfully:

1. I asked optimizer not to cache URLs with *artists_involved_filter=* in the plugin dashboard – the plugin saves this as a rule not to cache URLs with /*artists_involved_filter=* – this results in no page being cached

2. I tried adding

add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params');
function add_sgo_bypass_query_params( $bypass_query_params ) {
    // Add custom query params, that will skip the cache.
    $bypass_query_params[] = 'artists_involved_filter=';

    return $bypass_query_params;
}

in functions.php, but pages with that string are still being cached.

What am I doing wrong?

Thank you in advance for any comments/suggestions

Giacomo Bruzzo

  • This topic was modified 1 hour, 33 minutes ago by gbruzzo.
  • This topic was modified 1 hour, 31 minutes ago by gbruzzo.
  • This topic was modified 1 hour, 23 minutes ago by gbruzzo.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer