How to add javascript code in wordpress site?

Hi. I am facing a issue from the last few days. I wanted to do some changes in my website.
I want that when user is on the site after few minutes a pop up appear that ask for login. I have written code for it. But the issue is where to put the js code in the main theme or in the child theme.

Thanks in advance!

Hi @MarveenJoee, always in the child theme – otherwise your changes will get lost with each update of the parent theme. So put your JS in the child theme folder, and enqueue it in its functions.php:

wp_enqueue_script('my-script', get_template_directory_uri() . '/assets/js/my-script.js');

I’m not understanding what you’re wanting to do. Why would a visitor need to log into the blog? It seems if they are able to access the ACP they would not need a pop-up and would know to use the link in the footer.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.