One of my pages uses the archive.php template only. Why?

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?

Edit

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  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.