How to detect the default page template in WordPress
This is a quick post. When you need to check which template a page is using, you’d normally call is_page_template(). But how do you detect when the default template — page.php — is active? Passing it by filename doesn’t always work reliably.
Problem: How do you check whether the default page template is in use?
Solution: Here are two reliable ways to handle this:
Option 1 — check the template filename directly:
if ( basename( get_page_template() ) === 'page.php' ) {
// default template is active
}
Option 2 — check that it's a page with no custom template assigned:
if ( is_page() && ! is_page_template() ) {
// default template is active
}
NOTE: Option 2 (is_page() && ! is_page_template()) is the more reliable check because get_page_template() can return different values depending on how the template was registered. Use Option 2 unless you specifically need to match the exact template filename.
Sources: