Slider with WP_Query in Wordpress does not work well [closed]

1

I have 2 sliders (.slide1 and .slide2) at the start of my website. If it is a mobile I show .slide1 and hidden .slide2, and if not then vice versa. Both sliders work but I want them to show 3 pictures only, and the problem is that they show more things besides those photos, there are moments when it stays empty without showing anything, I do not understand it.

Code of slide1 (the .slide2 is the same only that it attacks other 3 posts):

<div class="slide1">  
<?php
  $slider = new WP_Query(array(
      'post_type' => 'post',
      'posts_per_page' => 100,
      'post_status' => 'publish',        


  ));

  if($slider->have_posts()) :
  while($slider->have_posts()) : $slider->the_post(); 
  //if ( in_category( 3 )  : 
  if( (get_the_ID() == 76) OR (get_the_ID() == 78) OR (get_the_ID() == 80)) :
      echo "<br/>-->".get_the_ID();
?>

    <div class="w3-display-container mySlides mySlidesPortada">
        <a href="#"><?php the_post_thumbnail('large'); ?></a>
    </div>

  <?php 
  endif;
  endwhile;
  endif;
  ?>
</div>

And the script:

<script>


var slideIndex = 0;
carousel();

function carousel() {
    var i;
    var x = document.getElementsByClassName("mySlides");
    for (i = 0; i < x.length; i++) {
      x[i].style.display = "none"; 
    }
    slideIndex++;
    if (slideIndex > x.length) {slideIndex = 1} 
    x[slideIndex-1].style.display = "block"; 
    setTimeout(carousel, 4000); // Change image every 2 seconds
}
</script>
    
asked by Ruiz86 12.12.2018 в 08:15
source

0 answers