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.

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

share|improve this question

migrated from stackoverflow.com Jan 15 '12 at 3:22

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

up vote 2 down vote accepted

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

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

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!

share|improve this answer
add comment

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.