Title: EddJB's Replies | WordPress.org

---

# EddJB

  [  ](https://wordpress.org/support/users/eddjb/)

 *   [Profile](https://wordpress.org/support/users/eddjb/)
 *   [Topics Started](https://wordpress.org/support/users/eddjb/topics/)
 *   [Replies Created](https://wordpress.org/support/users/eddjb/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/eddjb/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/eddjb/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/eddjb/engagements/)
 *   [Favorites](https://wordpress.org/support/users/eddjb/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Using query_posts within a shortcode](https://wordpress.org/support/topic/using-query_posts-within-a-shortcode/)
 *  Thread Starter [EddJB](https://wordpress.org/support/users/eddjb/)
 * (@eddjb)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/using-query_posts-within-a-shortcode/#post-3601797)
 * For anyone searching for this, Alchymth’s solution worked almost immediately.
   I had to remove my own mistake of the incorrect
    `<li>` tag. Beyond that, the
   only slightly strange thing was that the `<!-- Closing the class slide -->` added
   a <p> tag which cycle.js treated as another slide. Once removed it all worked
   perfectly.
 * Full code was
 *     ```
       <?php
       function l_carousel( $atts, $content = null ) {
   
       $output = '';
       $carousel_query = new WP_Query('post_type=carousel&showposts=10');
       if ($carousel_query->have_posts()) :
       $output .= '<div class="carousel">';
       while ($carousel_query->have_posts()) : $carousel_query->the_post();
       $output .= '<div class="slide">';
         if(has_post_thumbnail())
       	{
         $output .= get_the_post_thumbnail($post->ID,'featured_image');
       	} else {
         $output .= '<img width="460" height="280" src="/image/placeholder.jpg" class="attachment-featured_image wp-post-image" alt="" />'; }
       $output .= '</div>';
   
       endwhile;
       $output .= '</div>';
       endif;
       wp_reset_postdata(); 
   
       return $output;
   
       }
   
       add_shortcode( 'carousel', 'l_carousel' ); ?>
       ```
   
 * Thanks to Alchymyth again!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Using query_posts within a shortcode](https://wordpress.org/support/topic/using-query_posts-within-a-shortcode/)
 *  Thread Starter [EddJB](https://wordpress.org/support/users/eddjb/)
 * (@eddjb)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/using-query_posts-within-a-shortcode/#post-3601788)
 * Thanks alot. Stupidly I hadn’t yet read the Shortcode API, which would have been
   a good starting point. Many thanks for your help! Hopefully I’ll be able to work
   it out from here.

Viewing 2 replies - 1 through 2 (of 2 total)