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'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts.

From the documentation i gather this should work:

query_posts( array('post_type' => array('post', 'product') ) );
while (have_posts()) : the_post();
   the_title();
   the_excerpt();
endwhile;

But that turns a weird list, made of pages !

Note that I've put it outside the loop.

What am i doing wrong?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

almost! when doing it outside of the loop, you have to reset the query as in:

wp_reset_query();
share|improve this answer

I would use a new WP_Query. Using query_posts is intended for the main loop only.

When should you use WP_Query vs query_posts() vs get_posts()?

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.