php - WordPress archive page "no posts" addion -


my code:

<?php  $today = date('d/m/y');  $the_query = new wp_query( array( 'post_type' => 'show', 'meta_key' => 'date', 'meta_value' => ''.$today.'' ) );     // loop  while ( $the_query->have_posts() ) : $the_query->the_post();   require('post.php');  endwhile;    // reset post data  wp_reset_postdata();  ?>

how can add "theres no posts" when have posts = 0?

just ad if , else conditions

    <?php      if ($the_query->have_posts()) :     while ( $the_query->have_posts() ) : $the_query->the_post();      // contents goes here      endwhile;       else :      echo "<h2>there no post</h2>";      endif; ?> 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -