I have spent a long time trying to figure out how to enqueue jquery into WordPress using the accordion and tabs UIs as my test, and I've walked away from this several times because I just gave up.
I recently stumbled over a suggestion online to put the enqueue code before the wp_head()
and the script after it.
I tried this with zero expectations, and it actually worked.
The full code I'm using in my header for my little test is:
<?php wp_enqueue_script('jquery'); ?>
<?php wp_enqueue_script('jquery-ui-core'); ?>
<?php wp_enqueue_script('jquery-ui-accordion'); ?>
<?php wp_enqueue_script('jquery-ui-tabs'); ?>
<?php wp_head(); ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$( "#accordion" ).accordion();
$( "#tabs" ).tabs();
});
</script>
Can anyone tell me if this is bad coding? Am I going to run into a problem down the road?
Thank you.