• Resolved NR Dev

    (@anown2)


    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)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not quite following. The while line would only act when there are posts to display. Not sure which part you’re wanting to check against. A value from the term that has the category ID 27? Something on the post itself, from the posts that have that term assigned?

Viewing 1 replies (of 1 total)
  • The topic ‘Check if custom post type has entry’ is closed to new replies.