Stop loop after 2 entries
-
Hi!
My website starts with a slideshow as opener.
The code defines that the slide gallery reads out postings of my photo portfolio.
The loop never ends – when the last pic is reached it starts over again.How can I define that the loop stops after 2 entries in my portfolio?
Here’s the code:
<script type="text/javascript"> jQuery(function($){ $.supersized({ // Functionality slide_interval : <?php echo of_get_option('sl_pausetime'); ?>, transition : <?php echo of_get_option('sl_effect'); ?>, transition_speed : <?php echo of_get_option('sl_animation_speed'); ?>, // Components slide_links : 'blank', // Individual links for each slide (Options: false, 'num', 'name', 'blank') slides : [ // Slideshow Images <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); ?> <?php if(qtrans_getLanguage() == "de"){ $wp_query->query("post_type=portfolio&portfolio_category=slider_de&showposts=-1"); } if(qtrans_getLanguage() == "en"){ $wp_query->query("post_type=portfolio&portfolio_category=slider_en&showposts=-1"); } ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large-thumbnail' ); $thumb_small = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'small-thumbnail' ); $url = $thumb['0']; $url_small = $thumb_small['0']; ?> {image : '<?php echo $url?>', title : '<?php the_title(); ?>', thumb : '<?php echo $url_small?>', url : '<?php the_permalink(); ?>'}<?php if(($wp_query->current_post + 1) == ($wp_query->post_count)) { echo ''; } else { echo ','; } ?> <?php endwhile; ?> <?php $wp_query = null; $wp_query = $temp;?> ] }); }); </script>
Thank you so much!
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Stop loop after 2 entries’ is closed to new replies.