I have a custom post type that I want to use an if/elseif/else statement with. If post count of post type is equal to 1 do X, elseif post count is greater than 1 do Y, else do Z.
This is the code I've come up with so far, but when I add in the count post type the_content and the_title start to pull in normal pages, not custom post types. Also, I'm pretty sure it's not actually counting the posts either. If I remove the if/elseif/else the while loop works perfectly.
PS. I stripped out the code in my while loop to make it more simplified. The normal code is much more complicated for the slider. The slider operates even with one slide so I need the first if statement to omit the slider if only one post.
function getTestimonial() {
$args = array( 'post_type' => 'testimonial' );
$loop = new WP_Query( $args );
$count_posts = wp_count_posts( 'testimonial' );
if(count($count_posts) == 1) :?>
<?php the_content(); ?>
<?php the_title(); ?>
<?php elseif(count($count_posts) > 1) : ?>
<?php if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>
<div id="slider">
<?php the_content(); ?>
<?php the_title(); ?>
</div>
<?php endwhile; endif; ?>
<?php else: ?>
<p>No listing found</p>
<?php endif;
}