WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I think thats what its called...

Basically a conditional statement if there are any posts in a specific custom post type/custom taxonomy, show posts, it not show an img or include whatever…?

But cycle through a few custom post types?

Checking in each if there is a post in the featured custom tax and if not skip on to the next one, ending up if a temp image or something...

So a conditional tag with query i suppose…

<?php $loop = new WP_Query( array( 'post_type' => 'profile','profile-type' => 'featured','posts_per_page' => '-1' ) ); ?>
show post details

else if
<?php $loop = new WP_Query( array( 'post_type' => 'films','film-type' => 'featured','posts_per_page' => '-1' ) ); ?>
show post details

etc etc

show include or temp image

Can it be done, or asking a bit too much of the technology?

Many thanks for any help :)

share|improve this question
up vote 0 down vote accepted

You can use the have_posts function. For more information, visit The Loop

$loop1 = new WP_Query( array( 
    'post_type' => 'profile',
    'profile-type' => 'featured',
    'posts_per_page' => '-1' ) );
$loop2 = new WP_Query( array( 
    'post_type' => 'films',
    'film-type' => 'featured',
    'posts_per_page' => '-1' ) );

if($loop1->have_posts()) {
    while($loop1->have_posts()) {
        // content here
} elseif($loop2->have_posts()) {
    while($loop1->have_posts()) {
        // content here
} else {
    // content if all else fails
share|improve this answer
Interesting, i'll give that ago and see how i get on, thanks :) – Jezthomp Jul 27 '11 at 14:02
I've put that in my template but it results in the page not loading at all. I need 3 loops though and where it says content here, i need to add an include... get_template_part( 'includes/enter' ); Is that possible? – Jezthomp Jul 27 '11 at 18:36
@Jezthomp - Sorry for the error. I miswrote the code and left out two end parenthesis. I have updated the code above. and get_template_part should work like any other code. – imHavoc Jul 27 '11 at 23:28

Your Answer


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.