Check if custom post type has entry
-
Good day,
Very good plugin my question is how to check if the custom post type has content? Currently here is my code:
<?php wp_reset_postdata(); // reset the query ?> <h2 id="virgina">Virginia</h2> <?php $custom_query = new WP_Query( array( 'cat' => 27, 'post_type' => array( 'post', 'trainer' ) , 'posts_per_page' => -1 )); while($custom_query->have_posts()) : $custom_query->the_post(); ?> <div class="row"<?php post_class(); ?> id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <div class="location"><?php the_field('area'); ?></div> </div> <?php endwhile; ?>
I just want to check if there is a content for category 27. Note the code above is already working but client want to add more and wont display until there is a post to the custom post type category.
Thank you in advance.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Check if custom post type has entry’ is closed to new replies.