WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Well, i'm creating a wordpress theme, but i can't get wordpress loop to work correctly for some reason. This code works fine in index.php :

if (have_posts()) :
   while (have_posts()) :

But, it does not work in my blog.php page(it's not a template, it's actually a shortcode). The shortcode works correctly for sure. But when the above code is executed it just prints NULL. If i try to grab the_content, the page loops indefinitely.

Any idea why this can be happening ?

share|improve this question
What do you mean by, "it's not a template, it's actually a shortcode"? Also, in what context, and/or in what template file, are you using blog.php? – Chip Bennett Jul 14 '11 at 12:01
up vote 0 down vote accepted

Within your blog.php file you need to declare <?php wp_head(); ?> without this the loop will not work and only so many items within $post will be available to you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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