Reputation: 438
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();
?>
Upvotes: 1
Views: 2383
Reputation: 4052
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.
Upvotes: 2