Numbering IDs
-
I’m implementing jquery tabs and I need to number the IDs of #tab and src=”#tab” so that they match-up. I’m trying to use <?php echo $wp_query->post_count+1; ?> but on the second loop it keeps counting rather than starting over.
Here’s what I’m trying to do:
<ul class="tabs"> <?php rewind_posts(); ?> <?php $loop = new WP_Query( array( 'post_type' => 'about sections', 'order' => 'asc', 'offset' => '1') ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <li><a href="#tab<?php $my_post_count++; echo $my_post_count; ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <div class="tab_container"> <?php rewind_posts(); ?> <?php $loop = new WP_Query( array( 'post_type' => 'about sections', 'order' => 'asc', 'offset' => '1') ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div id="tab<?php $my_post_count++; echo $my_post_count; ?>" class="tab_content"> <?php the_content(); ?> </div> <?php endwhile; ?> </div>
Any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Numbering IDs’ is closed to new replies.