I try to get latest WordPress posts in carousel, I received no error but also no results!

here is the code I’m using :

<div class="jumbotron">
                    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">

                <?php

                    $my_query = new WP_Query();
                    $my_query->query('showposts=12');
                  $x==0;
                  $do_not_duplicate = $post->ID;
                  echo '<ol class="carousel-indicators">';
                  while ($my_query->have_posts()) : $my_query->the_post();
                    echo '<li data-target="#carousel-example-generic"data-slide-to="'; echo $x; $x++; echo '"';
                    if( $x==0 ){ echo'class="active" ';  } echo'></li>';
                  endwhile ;
                  echo' </ol>';
                ?>
              <!-- Carousel items -->
              <div class="carousel-inner">
            <?php $x==0; while ($my_query->have_posts()) : $my_query -> the_post(); ?>

                <div class="<?php if($x==0){echo 'active item';}else{echo 'item';} ?>">
                    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php echo get_the_post_thumbnail($id, 'sliderimg'); ?></a>
        <div class="carousel-caption"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
                </div>

                <?php endwhile; ?>
              </div>

              <!-- Carousel nav -->
                <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left"></span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right"></span>
                </a>
              <?php wp_reset_query(); ?>
          </div>
        </div>

Here is my JS:

jQuery(document).ready(function($) {
    $('.carousel').carousel({
        interval: 1000  
    })
});

Please help me if you have any idea.

Sorry guys but here is dummy text just to this site let me post my question! my question was simple and clear i don’t know what more should i say till be able to post my question!.

Read more here: WordPress latest posts carousel


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: