loading jQuery/JavaScript in functions.php (wordpress) -


I am trying to load a Google Maps function in the functions.php file of my WordPress theme.

  & lt; script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; script src = "http://maps.googleapis.com/maps/api/js?sensor=false&ext;extension=.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; & Lt; ! - Update page (); // -> & Lt; / Script & gt; & Lt; / Script & gt;   

I have been asked by the creator of the topic to call it in .php file in the wp_enqueue_script () function.

My problem is that when I try to call it, & lt; Creating problems ... Apparently I do not know how to call it in the correct format .... how can I insert it correctly so that mine Should Fullscreen Google Maps Work Right?

You must create a .js file for the Jquery code you want to run.

For the purposes of this example, I want to name this file as customjquery.js . You can name whatever you want, but if you do, be sure to edit the code below to display the new file name.

1] a customjquery.js file:

  (function ($) {updatepage ();} ) (jQuery);   

2] You then need to put that custom jquery.js file in the / js / directory of your subject.

3] Add this code to your code functions.php file:

  function my_custom_scripts () { wp_enqueue_script ('jquery'); wp_enqueue_script ('google-maps-api', '//maps.googleapis.com/maps/api/js?sensor=false&extension=.js', array ('jquery')); wp_enqueue_script ('my-custom-jquery', get_template_directory_uri (). '/js/customjquery.js', array ('jquery')); } add_action ('wp_enqueue_scripts', 'my_custom_scripts');   

If you want to put a customjquery.js file elsewhere in your topic folder, simply copy the path in the code above to reflect the new location of the file. Update .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -