Looping single post in a theme

  1. Firstly, you don’t need to check with is_single() in single.php. WordPress will automatically recognize it for single post.
  2. Secondly, breakdown your template with in parts. Such as break your main loop code in content-single.php and call it in single.php with get_template_part('content', 'single').

So you single.php template will look like below-

<?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part('content', 'single-heading');?>
<?php endwhile; ?>
<?php //sidebar widget goes here  ?>
<?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part('content', 'single');?>
<?php endwhile; ?>

And create two files content-single.php and content-single-heading.php in the directory where single.php is. Then put below code in content-single.php

<div class="post-content">
   <!--Post content and footer goes here-->
</div>

And this piece of code in content-single-heading.php

<div class="post-heading-info">
   <!--Post heading info like title, category goes here -->
</div>

That will make your theme code more maintainable. And for further information read WordPress codex and analyze WordPress default themes.

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.