How to display posts with images in fullscreen slider

You can use this code bellow with Query:

   <div class="w3-content w3-display-container">
<?php
  $slider = new WP_Query(array(
      'post_type' => 'post',
      'posts_per_page' => 5,
      'post_status' => 'publish',        


  ));

  if($slider->have_posts()) :
  while($slider->have_posts()) : $slider->the_post();
?>

<div class="w3-display-container mySlides">
<a href="">
  <?php the_post_thumbnail('large'); ?>
  <div class="w3-display-bottomleft w3-large w3-container w3-padding-16 w3-black">
    Trolltunga, Norway
  </div>
  </a>
</div>

  <?php 

  endwhile;
  endif;

  ?>


<button class="w3-button w3-display-left w3-black" onclick="plusDivs(-1)">&#10094;</button>
<button class="w3-button w3-display-right w3-black" onclick="plusDivs(1)">&#10095;</button>

</div>

<script>
var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = x.length}
  for (i = 0; i < x.length; i++) {
     x[i].style.display = "none";  
  }
  x[slideIndex-1].style.display = "block";  
}
</script>