Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url

WordPress parses incoming URLs with a list of regular expressions, the rewrite rules. The first regex that matches the URL “wins”, and determines what kind of query will be executed. You can see the rewrite rules and play with different URLs with my Rewrite analyzer plugin.

Whether or not pages take priority over other rules depends on your permalink structure. If it contains %postname%, %category%, %tag%, or %author% as the first permastruct, the rewrite engine will generate verbose page rules, where each page gets a specific rule at the top of the list instead of a catch-all rule at the end. This can explain the difference between the two sites.

The WP_Rewrite::rewrite_rules() function that generates the rules has many different filters. You can hook into one of them to modify the array, so that the most important rules for you are at the top. You can find many questions on this site with examples of how to modify these rules.

Leave a Comment