I've taken a very minimalistic loop, and tried to modify it, so that I can use more then one loop on one page.
The minimalistic loop works fine and gets the content. But my modification to allow it to be re-used fails.
This is the working loop:
<?php if (have_posts()) :
<?php while (have_posts()) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?>
All good so far. That actually works. But if I want to have more then one loop on a page, I'm forced to work with WP_Query.
So, I modify my loop thus:
<?php $my_query = new WP_Query() ; if ($my_query->have_posts()) :
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php $my_query->the_content(); ?> <?php endwhile; ?>
But now I get nothing back at all. I don't get any errors, and php after that loop continues to execute. But I'm not getting any content.
Where am I going wrong? How do I actually get the content?