jQuery Accordion using categories and child cat titles
-
Have read extensively how to use a jQuery accordion in a custom theme I’m attempting. The accordion I’m trying to make would be all categories (and child cats) of id ‘4’ or name ‘programs’ Here’s what I have so far but not working. Function doesn’t seem to be used and is not nesting the cats either; even in the hardcoded attempt (see template below). Thx for any help you can offer.
ref: https://howlingwolfmedia.com/site3/class-categories/functions file:
https://pastebin.com/naZTzHDtif(!is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery', ('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'), false, '1.6.4'); wp_enqueue_script('jquery'); wp_deregister_script('jquery-ui'); wp_register_script('jquery-ui', ('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'), false, '1.8.16'); wp_enqueue_script('jquery-ui'); }
document read file:
https://pastebin.com/gPRNtbLgjQuery(document).ready(function($){ $('#accordion').accordion(); });
header calls to jQuery
https://pastebin.com/b9W9ak32<!-- Add the link to the jQuery UI stylesheet 'before' the site CSS file so you can override properties as needed --> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo get_stylesheet_directory_uri(); ?>/css/ui.theme.css/" /> <!-- add js file that invokes the jQuery UI accordion file here source: https://www.ethangardner.com/articles/add-a-jquery-ui-accordion-widget-area-to-a-wordpress-theme/ --> <script src="<?php echo get_stylesheet_directory_uri(); ?>/js/ux.js"></script> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
template using accordion function
https://pastebin.com/i7kawD4j<div class="accordion"><!-- attempt hard code first --> <h3><a href="#">First header</a></h3> <div>Content 1 default as collapsed</div> <h3><a href="#">Second header</a></h3> <div>Content 2 default as collapsed</div> </div> <!-- accordion dynamic --> <div class="accordion"> <?php $args=array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => FALSE, //important or will not display at all since some cats may have no posts 'child_of' => 4, 'display' => 'linear' ); $categories=get_categories($args); foreach($categories as $category) { echo ' <a href="#">' . $category->name.'</a>'; } ?> </div>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘jQuery Accordion using categories and child cat titles’ is closed to new replies.