rewrite rules – Auto Pretty URLs for Woocommerce category filtering URLs?
Question
We are looking to rewrite the Woocommerce products filtering URL like this:
https://www.weddingguestdresses.com/?filter_length=midi&filter_silhouette=mermaid&filter_color=ink-blue&query_type_color=or
Into pretty URL like this:
https://www.weddingguestdresses.com/filter/midi/mermaid/ink-blue/
Thus far, we have this in functions.php:
add_action( 'init', function() {
add_rewrite_rule(
'^filter/([^/]*)/([^/]*)/([^/]*)/?$',
'index.php?filter_length=$matches[1]&filter_silhouette=$matches[2]&filter_color=$matches[3]&query_type_color=or',
'top'
);
} );
We also refreshed the permalinks by Settings > Permalinks > Save Changes.
But as you can see at this URL: https://www.weddingguestdresses.com/filter/midi/mermaid/ink-blue/
It’s just the plain shop home page without any filtering at all.
How can I make this work? Is it possible at all?
0
10 months
2022-03-29T10:18:06-05:00
2022-03-29T10:18:06-05:00 0 Answers
0 views
0
Leave an answer