Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134420

jtm12 on "Enqueue jquery to use accordion and tabs"

$
0
0

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.


Viewing all articles
Browse latest Browse all 134420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>