Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 :

<?php
if (have_posts()) :
   while (have_posts()) :
      the_post();
      var_dump($post);
   endwhile;
endif;
?>

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

1 Answer 1

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

 
discard

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.