1

I'm creating a single page site and obviously want to include the blog posts. I'm currently looping through the pages and using the_content() and the_title() to display them. However, the_content doesn't include the blog posts on the blog page. I tried another loop in this one, but it didn't work. Any ideas to point me in the right direction? Thanks

2

To include posts and pages in the loop, use the 'post_type' argument:

<?php
$wp_query = new WP_Query();
$args = array(
     'post_type' => array('post','page')
);
$wp_query->query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>

<?php the_content(); ?>

<?php endwhile; ?>

http://codex.wordpress.org/Class_Reference/WP_Query

| improve this answer | |
  • Ah didn't think to use post_type, thanks a bunch. I can definitely use this help. Thanks! – ttt Jan 15 '12 at 12:36
0

From http://codex.wordpress.org/The_Loop_in_Action

if (have_posts()) :
  while (have_posts()) :
    the_post();
    the_content();
  endwhile;
endif;

More info: http://codex.wordpress.org/The_Loop

If you want more help, post some code!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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