How do I include js without register/enqueue?

Yes, you can use get_template_directory_uri to refer to the theme root path. <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/244554/<?php echo get_template_directory_uri();?>/js/amplitude/amplitude.js”></script> But prefered way of doing is to use wp_enqueue_script().

trying to enqueue script in wordpress

You actually don’t need to worry about conflicting with the admin pages anymore. There is a “wp_enqueue_scripts” hook that makes sure the scripts aren’t called on admin pages. From WP Codex: <?php function my_scripts_method() { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js’); wp_enqueue_script( ‘jquery’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); ?> But if you need a custom jQuery … Read more

How to add JS in footer

By Using wp_enqueue_script() You can add your scripts to a JS file and then enqueue it properly. I assume you have added your scripts to file.js. Here’s how you enqueue it in the footer: add_action(‘wp_enqueue_scripts’,’my_script_callback’); function my_script_callback(){ wp_enqueue_script( ‘my-script’, get_template_directory_uri().’/folder/file.js’, array(jquery), null, true ); } The last argument in wp_enqueue_script() determines whether your script should … Read more

Pass custom fields values to Google Maps

Here’s a version that uses wp_localize_script(), as suggested by others. It’s just a little bit cleaner, since you don’t mix your PHP with your JS, and generally a neat way to pass things from the server side to your JavaScript. First, put the following code either in your plugin or your functions.php (I use a … Read more

How to prevent text modified using gettext filter being stomped (presumably) by updateText() js function within a CPT’s edit screen

First, you have nasty typo in __contsruct. 🙂 Second, your hook timing is wrong. Related WP JavaScript is localized via postL10n object (you can see it echoed in page’s source), that gets put together on init hook – way earlier then admin_head and your filter is not in place yet. From quick test this should … Read more