How to create a collapsible set in a foreach loop within Wordpress
I have the following code working that allows me to list the Post Categories with each category item(s) listed under relative category-title. How do I incorporate jQuery Mobile technique to collapse the category item(s) under relative titles? here is my code:
- <div class="wrapper">
<div class="ui-body ui-body-f">
<h3>My List</h3>
<?php // cycle through categories, print 1 post for each category
$categories=get_categories('orderby=name&order=ASC');
foreach($categories as $category) {
$posts=get_posts('showposts=1&cat='. $category->term_id);
if ($posts) {
echo $category->name .' ';
foreach($posts as $post) {
setup_postdata($post); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
} // foreach($posts
} // if ($posts
} // foreach($categories
?>
</div>
</div><!-- /themed container -->
</div>