0

I'm trying to develop my first wordpress themes, but now I have a quite weird problem. My singular.php page seems to not work. whatever I put in the page doesn't show up. as if the wordpress core doesn't recognize the file. while I used the same content for another theme for the same website and it worked properly.

It doesn't even show my header and footer. and when I inspect the page it's completely empty!

I tried setting the index.php file, but the same result was there :( nothing to show. the content of the page is:

<!DOCTYPE html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php get_header();?>
</head>
<body>
<?php get_template_part('template-parts/header/header-bar');?>

<?php
if (have_posts()):
  while (have_posts()) : the_post();
    the_content();
  endwhile;
else:
  echo '<p>Sorry, no posts matched your criteria.</p>';
endif;
?>

<?php get_footer();?>
</body>
</html>

UPDATE

for some reason, this content works in page.php, I don't know why singular.php and index.php don't work. according to wordpress Template Hierarchy they should show the content in case of existence.

  • Doesn't sound like it's using that template at all. Check [the manual about template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) to make sure that you don't have any template that supersedes `singular.php` or `index.php`. However, if you get a blank white page (even no HTML source if you check "view source"), it could be a [White screen of death](https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php) – M. Eriksson Jun 15 '22 at 06:21
  • thanks for sharing your comment, I had an update on my question. Although my problem solved, I still don't know the reason why template-hierarchy didn't work ‍♀️ – sahar manouchehri Jun 15 '22 at 06:40

0 Answers0