I’m working on a custom WordPress theme built from the Underscores framework. I’ve created both single.php and page.php template files in my theme directory, but I’m running into a weird issue.
When I visit any of my WordPress pages, they’re being rendered using the single.php template instead of the page.php template. This is confusing because I thought WordPress automatically picks the correct template based on content type.
I’ve double-checked that my page.php file exists and is properly named. The file permissions look fine too. But for some reason, WordPress keeps defaulting to single.php for both posts and pages.
What could be causing this template hierarchy problem? Is there a way to force WordPress to use the correct page.php template for static pages?
hey, also try checking if your theme settings might be forcing single.php somehow or if there’s any plugin messing with it. it can be super confusing, and sometimes just re-saving permalinks does the trick too!
This happens when WordPress can’t detect your template hierarchy properly. I had the same issue - turned out I had a broken query or custom queries messing with the main one somewhere in my theme. Check your header.php and functions.php for any WP_Query or get_posts() calls that aren’t properly reset with wp_reset_postdata(). Also make sure your page.php doesn’t have syntax errors - just add some debug output at the top to test it. One more thing: look for conditional statements that might be forcing single.php to load instead. Sometimes custom template logic overrides WordPress defaults.
Had the exact same issue when switching themes. Turned out I’d accidentally registered a custom post type in functions.php that was messing with the default page setup. Check for any custom post type registrations or template_redirect hooks that might be causing problems. Also double-check that your pages are actually set as ‘Page’ post type in WordPress admin - during imports they sometimes get saved as ‘Post’ instead. You can verify this by editing the page or running a quick database query to check the post_type value. If they’re stored as posts instead of pages, that explains why single.php is loading.