M
M
Michael R.2015-10-09 13:52:18
JavaScript
Michael R., 2015-10-09 13:52:18

How to connect a new script to the footer in WordPress?

Hello! There is a script that needs to be displayed in the basement. According to Feng Shui, I know that I need to output scripts in the footer, but not directly in footer.php, but sort of through functions.js, but how to do it?
For example, I have an online form plugin, it requires the mandatory presence of this line in the template , that is, it is connected there. How can I include my script there? Thank you! <?php wp_footer(); ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Martirosov, 2015-10-09
@Mike_Ro

function load_my_scripts() {
  wp_enqueue_script('my-script-handline', 'ULR_TO_MY_JS_DIR' . 'my-script.js', array('jquery'), '', true);
}

add_action('wp_enqueue_scripts', 'load_my_scripts')

where is ULR_TO_MY_JS_DIRthe path to your script folder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question