0

This should be easy. I need to query to display one page in a tab. Just pull one page by one query, but I'm doing something (maybe lots) wrong here:

Edit: Hah. I forgot the_content It works now.

<?php

$the_query = new WP_Query; $the_query->query ('pagename=about' );

while ($the_query->have_posts()) : $the_query->the_post(); ?>

<?php the_content(); ?>  //forgot this

<?php endwhile; ?>
2
  • Query works fine for me, try chucking in a wp_reset_query() before (and possibly after) your custom query and see if that helps..
    – t31os
    Commented Apr 3, 2011 at 17:50
  • Thanks. That's a good point. But. Arggg... I forgot the_content. Works now. Commented Apr 3, 2011 at 18:39

3 Answers 3

1

Hah. I forgot <?php the_content(); ?>

0

Shouldn't this be $the_query = new WP_Query('pagename=about'); ?

2
  • 1
    Nope, either method is valid..
    – t31os
    Commented Apr 3, 2011 at 18:28
  • Ah ok - I didn't realise have_posts() also executed the query
    – anu
    Commented Apr 3, 2011 at 19:23
-1

If there is only one page to call, why use "while"? Look:

<?php $query = new WP_Query;
$query->query ('pagename=about');
$query->the_post();
the_content(); ?>
1

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.