How do you call javascript in wordpress?

Can I call a JavaScript function in Wordpress like this?


Where should I put my JavaScript? at footer.php? or what would be the proper way to achieve something like this?

I put my script in footer.php, then I called the function like as I mentioned but no use?

asked May 28, 2015 at 6:06

1

Yes you can use title="callGetDomain[];" and for the function definition, use a separate js file and include that file using wp_enqueue_script[], which is the proper way to call js files in Wordpress. Check this

answered May 28, 2015 at 6:10

Vidya LVidya L

2,2514 gold badges27 silver badges41 bronze badges

Do you want to add JavaScript in your WordPress pages or posts?

Sometimes you may need to add JavaScript code to your entire website or into specific pages and posts. By default, WordPress does not let you add code directly in your posts.

In this article, we’ll show you how to add JavaScript in WordPress pages or posts easily.

What is JavaScript?

JavaScript is a programming language that runs on the user’s browser, not on your server. This client-side programming allows developers to do a lot of cool things without slowing down your website.

If you want to embed a video player, add calculators, or some other third-party service, then you will be often asked to copy and paste a JavaScript code snippet into your WordPress website.

A typical JavaScript code snippet may look like this:

 

// Some JavaScript code



Chủ Đề