EddJB
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Using query_posts within a shortcodeFor 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
In reply to: Using query_posts within a shortcodeThanks 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)