I was wondering, what’s the difference, and best filter/action to add rewrite rules? I used all but I still can’t say why should I use one or the other.

add_action('init', 'add_rewrite_rules'); // or:
add_action('generate_rewrite_rules', 'add_rewrite_rules'); // or:
add_filter('rewrite_rules_array','add_rewrite_rules');

1 Answer
1

Use whatever is simplest for your needs.

If you just need to add a rule to the stack, use add_rewrite_rule on init.

generate_rewrite_rules and rewrite_rules_array give you access to the whole rewrite rules array. Use these if you need to modify, remove, or reorder the rules.

Leave a Reply

Your email address will not be published. Required fields are marked *