How to check it’s default page template?

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:

  1. https://gist.github.com/zackn9ne/3344158/
  2. https://wordpress.stackexchange.com/questions/149803/conditional-tag-to-check-if-page-php-is-being-used/