lundi 13 janvier 2020

Change displayed code based on number of posts Wordpress

I have a slideshow for my Wordpress posts. I would like to add an if statement so that if there is only one post in the database, the id "slideshow" is changed to "no-slideshow". Any help is appreciated :)

Here is my code:

<?php $args = array( 'post_type' => 'html5-blank', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    echo '<div id="slideshow"><div class="announce"><p><a href="#">';
    the_title();
    echo '</a></p></div></div>';
endwhile;
      ?>

Aucun commentaire:

Enregistrer un commentaire