I'm using add_rewrite_rule function to add this rule:
function custom_rewrite_rules() {
add_rewrite_rule(
'category/books/crime',
'category/books/?filter_category=crime',
'top'
);
flush_rewrite_rules();
}
add_action('init', 'custom_rewrite_rules');
But it only returns Error 404 Page not found.
When I use this kind of URL /?filter_category=crime
the result is ok. But I would expect this URL
return the same result because of added rewrite rule.
I'm also using WooCommerce plugin where "books" category and "category" attribute with "crime" term are created.
Is there something wrong in my function? If the function is good, where else could be the problem?