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