I'm looking to use the jQuery TreeView script on wp_list_pages to get a nice collapsable-tree effect going.
The script requires that I add some classes to the list elements such as:
<ul id="red" class="treeview-red">
So I tried putting this in my template:
First, load scripts on my template page via wp_enqueue_script()
wp_enqueue_script("av_jquery_tree");
get_header();
Where "av_jquery_tree" is defined in a plugin:
function av_jquery_tree() {
wp_register_script('jquery.treeview', get_template_directory_uri() . '/js/jquery.treeview/jquery.treeview.js', array('jquery'), '1.0' );
wp_register_script('jquery.cookie', get_template_directory_uri() . '/js/jquery.treeview/jquery.cookie.js', array('jquery'), '1.0' );
wp_enqueue_script('jquery.treeview');
wp_enqueue_script('jquery.cookie');
}
add_action('wp_enqueue_scripts', 'av_jquery_tree');
Second, In order to add the class and id to the first ul element on the page, I just insert this script above the call to wp_list_pages:
<script>
jQuery(document).ready(function(){
jQuery("ul").first().attr("id", "red").addClass("treeview-red");
});
</script>
Unfortunately, my output is just a bunch of red lines across wp_list_pages. Also keep in mind that I'm using the Suffusion Theme, which preloads jquery.
wp-includes
dir? Dont modify core! 3rd: That's a "Tree", not an "Accordion". 4th: You ask that many Qs, that you should know about "The title should tell about the Q." ... and "help!" doesn't add anything to it.