3

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?

6

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();

?>
  • Thank you for all the help. Yes, I want this in the same loop. @Anu: I tried following the suggestion. This is the code I came up with. <?php query_posts ( array('post_type' => array('cat=1', 'portfolio', 'Year of Article' => '2011' ) )); //loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> Unfortunately, it only shows the custom post type (Press Articles) not the posts. brooklyngreenway.org/?page_id=1037&preview=true @Anu, did I do something dumb? Thank you for any help. – Jeff Tancil Mar 4 '11 at 19:13
  • I've updated my answer, but you've added some extra parameters (eg Year of Article) that aren't to do with the original question – anu Mar 8 '11 at 13:22

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.