I am building my own WordPress theme. I have the front page working. However, when I try to view a test post full of Lorem Ipsum, I get the "No matching template found" error.
I have the following code in single.php
<?php
get_header();
if( have_posts()){
while( have_posts() ){
the_post();
the_content();
}
}
get_footer();
?>
single.php is under directly my custom theme's root folder.
From what I understand, the page should just display the content, albeit without much styling. I navigated to the post using the "view post" link on the post edit page if that matters.
Just to be sure, I also placed the same code in page.php, index.php, and page.php
No success. No matter what I try, I still get "No matching template found" when navigating to the test post.
What am I missing here? Is there a way to troubleshoot the template hierarchy?
Thanks in advance.
index.php
file? Themes must have anindex.php
file to be valid, and that file acts as the final fallback at the end of the template hierarchy. What you're describing does not make sense in a valid theme. The absolute minimum required theme needs astyle.css
and anindex.php
, even if you do not intend to use those files they must be present. Likewisesingle.php
must be at the top level of the theme it cannot be inside a subfoldertheme.json
? Or have set up a template for that post using the UI? It's possible to override the template of a single page and create a block based template