I created a page and experimented with Custom Templates. Suddenly I noticed that this page started using the archive.php template and no matter which Custom Template I assigned to it, it continues using the archive template. What could be the reason for this?


I noticed something interesting. I have a Custom Post Template that has the exact same slug as the page described above. I made another CPT and a page with the same slug and got the same effect. If I change the page slug it starts using the assigned Custom Template.

This behaviour seems kind of convenient but why is WP behaving like this? Is it documented anywhere? I'd would be very interesting to read.

  • -1 for not nearly enough information to answer this question. It cannot be answered in a vacuum. We need to know relevant filenames, see relevant code, etc. Jun 9, 2012 at 15:53
  • Well I would have added more information if I had know what's relevant. The way some parts of the template hierarchy works is still black magic to me. I'm very grateful for all the information I get that help me understand.
    – ivvi
    Jun 9, 2012 at 17:15
  • I would start with: your custom template filename and code, your CPT registration code, and live links to pages demonstrating the issue. Jun 9, 2012 at 18:34
  • I'm building this site for a customer an it is therefore not yet public. At the moment I'm very busy and it works consistently, but I'll make a new site that exhibits this phenomenon in a few days with posts of the code too. It could be due to what Milo described.
    – ivvi
    Jun 11, 2012 at 6:04

1 Answer 1


When you use pretty permalinks, WordPress creates a set of rules for each type of content. These rules define a pattern that each type of content's URL's will follow.

When you have an incoming request, WordPress decides what is being requested by matching the URL with these rules. If multiple rules match, the one with the highest precedence is used. In this case, your CPT takes precedence over pages.

See the WP_Rewrite class in Codex for more info.

EDIT Also see parse_request in source for the code that parses these rules for a request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.