I have successfully got a local version of jquery accordion working ref: http://howlingwolfmedia.com/site3/classes/class-categories/
2 questions
- how to properly use wp_enqueue_script. Currently hardcoded header to local copy of jquery in my theme themename/jquery_ui/js/jquery-ui-1.10.3.custom.js, js/jquery-1.9.1.js and css/ui-lightness/jquery-ui-1.10.3.custom.css respectfully. I'm currently doing this in a multisite installation. And i see there is a min version of accordion in the 3.4.2 install /wp-includes/js/jquery/ui.
- How do i get the accordion to expand to content only vs. deepest content e.g. aerobic (with most titles for that cat) vs. nutrition
And here's the code used on the template:
<div id="accordion" style="width:95%;">
<?php
$args=array(
'child_of' => 4,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => '0'
);
$categories=get_categories($args);
foreach($categories as $category) {
echo '<h3>' . $category->name . '</h3>
<div>';
global $post;
$args = array( 'posts_per_page' => -1, 'category' => $category->term_id, 'orderby' => 'name', 'order' => 'ASC' );
//alternatively this also works: 'nopaging' => true
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
echo '<p><a href="' . get_permalink($post->ID) . ' " style="color:#7c7c7c; font-size: 1em; text-decoration:none !important; line-height:80%;">' . get_the_title($post->ID) . '</a></p>';
endforeach;
echo '</div>
';
}
?>
</div><