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 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(); ?> However, I am a PHP nitwit and have failed to combine the two calls in to one. Is this not feasible?

Thank you for any help.

share|improve this question
    
take a look at codex.wordpress.org/The_Loop#Multiple_Loops –  Bainternet Mar 3 '11 at 17:06
    
I've added an answer that assumes you want to show posts and your CPT in the same loop –  anu Mar 3 '11 at 17:12

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 is: http://codex.wordpress.org/Function_Reference/WP_Query#Post_.26_Page_Parameters

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

share|improve this answer
    
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

 
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.