How to fix WordPress custom theme issues where content doesn’t appear

Solution 1:

You can use a while loop to correctly retrieve and display the content:


<?php
while ( have_posts() ) : the_post();
    print_r( get_the_content() );
endwhile; // End the loop
?>

This works because WordPress requires the loop to access post data. I’ve tested it, and it works as expected.

Solution 2:

Using a while loop alone may not work in your case. The issue occurs because of how you’re including your header and footer files:


<?php get_header(); ?>
<?php get_header('content'); ?>
<?php get_footer('footer'); ?>

If you’ve created a file named header-content.php, WordPress will include it with get_header(‘content’). However, in your setup:

  • The footer isn’t showing because get_footer(‘footer’) expects a file named footer-footer.php. If that file doesn’t exist, nothing is displayed.
  • The content shows only the first 5 lines because the_post() or have_posts() loop isn’t properly used, or the_content() is not called inside the loop.

To fix this:

1. Ensure your custom header/footer files exist with the correct naming convention:

  • header-content.php → get_header(‘content’)
  • footer-footer.php → get_footer(‘footer’)

2. Wrap your content in the standard WordPress loop:


<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_content(); ?>
<?php endwhile; endif; ?>