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 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…

if
<?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

else
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

1 Answer 1

up vote 0 down vote accepted

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

<?php
$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()) {
        $loop1->the_post();
        // content here
    }
} elseif($loop2->have_posts()) {
    while($loop1->have_posts()) {
        $loop1->the_post();
        // 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

 
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.