I must be doing something wrong here.

I setup my site with a static front page using front-page.php. I created a page in the admin with a title and chose the front-page.php in the template dropdown.

My title shows up fine, however the_content(); does not.

I'm not doing anything special as shown below.

Template Name: Homepage
*/ ?>
<?php get_header(); ?>
<div class="content">
<div class="welcome_area">
<div class="welcome_area_title"><?php the_title('');?></div>
<div class="welcome_area_text">
<?php the_content(); ?>

Any ideas why the content won't show?

2 Answers 2


You don't really have a Loop.

<?php get_header(); ?>
<div class="content">
<div class="welcome_area">
<div class="welcome_area_title"><?php the_title('');?></div>
<div class="welcome_area_text"><?php 
if (have_posts()) {
  while (have_posts()) {
} ?>

What is happening is:

  1. You use have_posts() to check that you have post content. You can use an else clause to provide default content if you want.
  2. You loop through that content using while(have_posts())
  3. You run the_post() to setup the $post variable and also to increment the loop counter. Try that without the_post() an you get an infinite loop. This is the most critical part that was missing from your code.
  4. Now that the_post() has run, your post template tags should work as expected.

I didn't edit your code too radically but I'd bring that the_title into the Loop as well, even if it seems to be working. It really should be inside the Loop and it does not always work as expected outside of it.



  • What a silly mistake. I can't believe I missed that, it was a long day. Thanks for the catch. Commented Apr 2, 2013 at 15:41
  • 1
    You don't really need to use have_posts() in front-page.php; front-pate.php will only be used if there is a post to display. So you can just put the_post() in and leave the if and while statements out. Commented Jan 19, 2016 at 20:54
  • Technically that may be true Michael but you are going to start all sorts of bad habits and confusion with that recommendation.
    – s_ha_dum
    Commented Jan 19, 2016 at 21:11

Well first of all, if you set your page as the static front page, you don't need to associate the template with the page, and the template doesn't need a header. WordPress automatically uses the front-page.php template for a static front page, as per the template hierarchy.

To answer your question though, you need to call the_post() first to set up the global vars that the_content() function relies on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.