Filters with rewrite rules

Is it possible to make filters work with rewrite rules? I wrote this for my CPT archive:

// Register query vars
add_filter('query_vars', function ($vars) {
	$vars[] = 'tax';
	$vars[] = 'color';
	return $vars;
});

// Add the rewrite rule
add_action('init', function () {
	$cpt_slug = 'katalog';

	add_rewrite_rule(
		'^katalog/([^/]+)/([^/]+)/?$',
		'index.php?post_type=' . $cpt_slug . '&tax=$matches[1]&color=$matches[2]',
		'top'
	);
});

// Add rewrite tags
add_action('init', function () {
	add_rewrite_tag('%tax%', '([^&]+)');
	add_rewrite_tag('%color%', '([^&]+)');
});

If I go to /katalog/something/red I see archive template as expected, but no effect from filters

Hi, @timmse , sorry for ping, but is it possible to do it with bricks filters?

Bricks Query Filters read filter state from URL parameters, either the default brx_FILTERID=value format or a custom filter nice name configured on the filter element.

Custom WordPress rewrite vars like tax and color are not automatically treated as Bricks filter state just because WordPress resolves the archive URL. The archive/template route can still load correctly, but the Bricks filter controls need matching Bricks URL parameters/nice names, or custom code needs to translate those rewrite vars into the query/filter state you want.

So the practical options are:

  • use the normal Bricks filter URL parameters/nice names, or
  • add custom code that reads the rewrite vars and applies the matching taxonomy/meta query to the Bricks query.

Docs: Query Sort, Filter & Live Search | Bricks Academy