Querying custom posts and regular posts

I want to populate the “Greenway News” box on this page with the three latest headlines from the site’s Press section AND blog.

The blog is a regular WP blog and I am currently using this code to get my results:

<?php query_posts('cat=3&posts_per_page=3'); ?> 

The Press page is a custom post type. I can get the following code to work as well:

<?php
   query_posts( array( 'post_type' => 'portfolio', 'toolkit' => '2011' ) );
   //the loop start here
   if ( have_posts() ) : while ( have_posts() ) : the_post();
?>

Is this possible?

1 Answer
1

You’re nearly there, you just need to tell WP that you want to query posts as well as your Press CPT.

So:

query_posts( array( 'post_type' => array('posts', 'portfolio'), ...);

where portfolio is the name of your custom post type.

The relevant Codex page

[Update]

So this is how the query should look

<?php

  $args = array('post_type'=>array('posts', 'portfolio'));

  query_posts($args);

  if ( have_posts() ) : while ( have_posts() ) : the_post();

?>

Leave a Comment