Greetings. Tell me how to properly and safely connect the script inside the wordpress theme php file? add_action() works only for functions.php or am I mistaken?

    2 answers 2

    You can add a script to a topic using the wp_enqueue_script() function

    More information about this method can be found here .

    • I'm not asking how to add a script to the functions.php file. read pliz question and comments carefully - Vasya
    • @ Vasya you decide what you want, Alexandr answered your question - tCode

    You can simply throw js-nick in the folder with the site you need, and connect the js-nick connection for example in header.php or template.php of the form

     <script type="text/javascript">твой скрипт</script>