Linking to Files in Root Directory Outside of WP Installation

Your first attempt does not work because get_template_directory_uri returns the URL to your theme directory.

Your second attempt will work, but if you don’t want to hard code the domain you could either try using a root relative path or fetching the domain portion of your site url.

Relative path:

wp_register_script('circle-bounce', '/js/general.js', array( 'jquery', 'jquery-effects-core', 'jquery-effects-bounce'));

Domain:

$parts = parse_url(site_url());
$domain_url = $parts['scheme'] . '://' . $parts['host'];
wp_register_script('circle-bounce', $domain_url . '/js/general.js', array( 'jquery', 'jquery-effects-core', 'jquery-effects-bounce'));

Leave a Comment