tabbed posts in page template – no clear implementation
-
hi there im trying to get the ID of a custom post the be used as the CSS class for a <div> in a separate section of my page.
essentially i want to make the user able to add a post to their custom post archive and have the content appear automatically when queried from my page template as if it was a blogroll with edited css..
currently i am able to generate the data i need without any stylings or animations however once i begin to set up a tabbed interface for each of the posts i lose the ability to generate a new tab once a new entry is created by the user.
currently i am implementing the custom post query on my page like so:
<div id='page'> <?php $subtitle = get_post_meta($post->ID,"subtitle",true);?> <div id="pageheader"> <h1><?php echo ($subtitle) ? $subtitle : the_title();?></h1> </div> <div id="pagecontent"> <div id="tabs"> <ul> <?php $capnumber = '12'; $type = 'Product'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => $capnumber, 'ignore_sticky_posts'=> 1 ); $temp = $wp_query; // assign ordinal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); ?> <?php if (have_posts()) : while (have_posts()) : the_post();?> <li><a href="#fragment-1"><span><?php the_title(); ?></span><?php the_excerpt(); ?></a></li> <?php endwhile; ?> <?php endif; ?> </ul> <?php if (have_posts()) : while (have_posts()) : the_post();?> <div id="fragment-1"> <p><?php the_content();?></p> </div> <?php endwhile; ?> <?php endif; ?> </div> </div><!--/pagecontent--> </div>
the main issue is that in each new post queried by WP the elements;
<div id="fragment-1">
&<a href="#fragment-1">
are constantly given the same unique id.i need to be able to have these elements increase the fragment-no. by 1 for each post generated.
i have considered adding the following code to the page to force the addition of an integer to be added to the end of the CSS id ;
<? foreach _post; echo 1++; ?>
as you can probably tell i get a pretty big error so any help would be greatly appreciated.
- The topic ‘tabbed posts in page template – no clear implementation’ is closed to new replies.