1

What is wrong with my code in index.php? or maybe not in my code? I'm creating a new theme from scratch. Direction of files is correct. Theme is activated. But text is not showing up.

   <?php

get_header();

if(have_posts()) :
  while (have_posts()) : the_post(); ?>

<h2>hello</h2>
  <?php the_content(); ?>

  <?php endwhile;

  else :
    echo '<p>No content found</p>'

endif;

get_footer();

 ?>

1 Answer 1

2

You are missing a semicolon. echo '<p>No content found</p>' should be echo '<p>No content found</p>';, hence why you are getting the white screen of death. So the full code, looks like so:

<?php

get_header();

if( have_posts() ):
  while (have_posts()) : the_post(); ?>

  <h2>hello</h2>
  <?php the_content(); ?>

  <?php endwhile;

else:
    echo '<p>No content found</p>';

endif;

get_footer();

?>

If you are using WordPress 4+ and in development, you should edit your wp-config.php file in the project root. Set the constant WP_DEBUG on line 80 to true to look like this:

define('WP_DEBUG', true);

This will show the syntax errors in your code instead of a white blank screen...and of course change it back to false when you ship the production version.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.