b4thebigbang
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Specific div layout using wp_queryThe code I´m using is:
<div id="slider-wrapper"> <div id="slider"> <?php $slider_query = new WP_query('post_type=rt_slider&showposts=5'); while ($slider_query->have_posts()) : $slider_query->the_post(); $do_not_duplicate = $post->ID; ?> <?php $image_href = get_post_meta($post->ID, '_image_href', $single = true);?> <?php $slide_id = get_post_meta($post->ID, '_slide_id', $single = true);?> <?php $caption_title = get_post_meta($post->ID, '_caption_title', $single = true);?> <?php $caption = get_post_meta($post->ID, '_caption', $single = true);?> <?php $caption_link_href = get_post_meta($post->ID, '_caption_link_href', $single = true);?> <?php $caption_link_text = get_post_meta($post->ID, '_caption_link_text', $single = true);?> <?php if($image !== '') { ?> <img src="<?php bloginfo('template_directory');?>/images/slider/<?php echo $image_href;?>" alt="" title="#<?php echo $slide_id; ?>"/> <?php } // end if statement else { ?> <img src="<?php bloginfo('template_directory');?>/images/slide5.jpg" alt="" title="#<?php echo $slide_id; ?>"/> <?php } ?> <?php endwhile;?> <?php rewind_posts();?> </div> <?php while ($slider_query->have_posts()) : $slider_query->the_post();?> <div id="<?php echo $slide_id;?>" class="nivo-html-caption"> <p><span><?php echo $caption_title;?></span></p> <p><?php echo $caption;?> - <a href="<?php echo $caption_link_href;?>"><?php echo $caption_link_text?></a></p> </div> <?php endwhile;?> </div>And it generates the following output:
<div id="slider-wrapper"> <div id="slider"> <img src="http://localhost/wordpress/wp-content/themes/RallyTiming/images/slider/slider2.jpg" alt="" title="#slide2"/> <img src="http://localhost/wordpress/wp-content/themes/RallyTiming/images/slider/slider1.jpg" alt="" title="#slide1"/> </div> <div id="slide1" class="nivo-html-caption"> <p><span>Welkom op de website van RallyTiming</span></p> <p>RallyTiming is dé tijd waarnemer van het Nederlands Rallykampioenschap en het Nederlands Short Rallykampioenschap. Via onze websites voor pc, smartphone en tablet blijf je altijd op de hoogte van de laatste uitslagen! - <a href="http://www.rallytiming.nl/over_ons/">Meer over RallyTiming</a></p> </div> <div id="slide1" class="nivo-html-caption"> <p><span>Welkom op de website van RallyTiming</span></p> <p>RallyTiming is dé tijd waarnemer van het Nederlands Rallykampioenschap en het Nederlands Short Rallykampioenschap. Via onze websites voor pc, smartphone en tablet blijf je altijd op de hoogte van de laatste uitslagen! - <a href="http://www.rallytiming.nl/over_ons/">Meer over RallyTiming</a></p> </div> </div>Problem seems to be that instead of generating the caption 2 div, it generates the caption 1 div again…
Forum: Fixing WordPress
In reply to: Specific div layout using wp_queryThanks for the quick response!
You’re right about the posts. The example I gave contained two posts. Problem is, with the way I’m using nivo slider all the images must be grouped within the “slider” div and all the captions need a diff of their own.
It’s easiest for my client to have all the numbers come from the loop… I’ve tried to do it by adding a counter in the while-loop, but that didn’t give the result I’m after.
Thanks for the quick tip on rewind_posts(), started reading up on it, cheers!
Viewing 2 replies - 1 through 2 (of 2 total)