php - My new approach to wp_enqueue_script -


ok, i'm trying eliminate possible variables troubleshooting purposes. instead of in functions.php, i've dropped code in header.php file:

<?php $mdgtemplateloc = get_bloginfo( 'template_url' ).'/js/'; ?> <?php echo '<!-- ' . $mdgtemplateloc . ' --> ?> <?php wp_enqueue_script( 'hoverintent', $mdgtemplateloc.'hoverintent.js', array( 'jquery' ) ); ?> <?php wp_enqueue_script( 'mdmenuanimation', $mdgtemplateloc.'mdmenuanimation.js', array( 'hoverintent' ) ); ?> 

the result few white space insertions source , comment appears requested. understanding insert like

<script type="text/javascript" src="[url]/js/mdmenuanimation.js"></script> 

i want correct way, wp_enqueue_script has been giving me nothing. suspect i'm doing fundamentally wrong, can't find , nothing find through google or stackoverflow or wp codex helping @ all.

to clarify, here's had before, in functions.php file:

function mdg_setup_scripts() {   $mdgtemplateloc = get_bloginfo( 'template_url' ).'/js/';   wp_register_script( 'hoverintent', get_bloginfo('template_url').'/js/hoverintent.js', array( 'jquery' ));   wp_enqueue_script( 'hoverintent' );   wp_register_script( 'mdmenuanimation', $mdgtemplateloc.'mdmenuanimation.js', array( 'hoverintent' ));   wp_enqueue_script( 'mdmenuanimation' ); } add_action( 'wp_enqueue_scripts', 'mdg_setup_scripts' ); 

this produced no output ever called script. understand second more supposed be, isn't doing anything.

wp_enqueue_script() not output anything. you're using incorrectly.

you need create callback , add wp_enqueue_scripts action. typically belongs in functions.php file.

re-read docs. there examples of wanting do.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -