How to get images dynamically From wordpress to image slide?

I have designed a site which I am converting to wordpress site,as I am new to wordpress I am not able get images dynamically from wordpress for bootstrap image carousel

this is my code using<?php bloginfo(template_url); ?>

Read More

but i need posts: which goes something like this:

 <?php 
                        query_posts(array('category_name' => 'social', 'posts_per_page' => 5));
                        if(have_posts()) : while(have_posts()) : the_post() 

                    ?>

<li><?php the_post_thumbnail('social'); ?></li>

<?php endwhile;  endif;  wp_reset_query(); ?>

And here is my code for image slide

     <div class=" col-xs-12 col-sm-12 col-md-12 col-lg-12 topmargin">

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>


  <!-- Wrapper for slides -->

 <?php 
   $qArgs = array(
    'category_name' => 'mainslide',
    'posts_per_page' => '5'
   );

  $newQuery = new WP_Query($qArgs); ?>

  <div class="carousel-inner" role="listbox">
  <?php if($newQuery->have_posts()) : ?>
        <?php while($newQuery->have_posts()) : $newQuery->the_post(); ?>

            <div class="item">

                <?php echo get_the_post_thumbnail( $post->ID, 'full'); ?>

      </div>
       <?php endwhile;?>
        <?php wp_reset_postdata(); ?>
     <?php endif; ?>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

here is the screen shot

This is the error i am getting

Related posts

Leave a Reply

1 comment

  1. I recommend use wp_Query instead query_posts, for better understanding read this

    Now, try this:

    <?php 
       $qArgs = array(
        'category_name' => 'social',
        'posts_per_page' => '5'
       );
    
      $newQuery = new WP_Query($qArgs); ?>
    
      <div class="carousel-inner" role="listbox">
        <?php if($newQuery->have_posts()) : ?>
            <?php while($newQuery->have_posts()) : $newQuery->the_post(); ?>
    
                <div class="item">
    
                    <?php echo get_the_post_thumbnail( $post->ID, 'full'); ?>
    
                </div>
    
            <?php endwhile;?>
            <?php wp_reset_postdata(); ?>
         <?php endif; ?>
      </div>