The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Changing the default url/file path for wp_enqueue (3 posts)

  1. Richard K
    Posted 4 years ago #

    We're running a WordPress Network and want to change the default path that get's prepended when wp_enqueue_style or wp_enqueue_script script are used. How can we change this?

    For some of our own scripts, we can simple add the full address, but for the plugins we use, we want them all to load from the same location for cashing reasons.

    So currently we'd use i.e.
    wp_enqueue_script('sn-default', get_bloginfo('template_url').'/js/default.js', 'jquery');
    which results in:


    But we want it to be:


    How can we set this default?

  2. David Gard
    Posted 4 years ago #

    You'd need to set a constant (possibly in one of the core files that is used by the whole network, but probably better in each of the sites functions files so that it doesn't get overwritten).

    define('MY_SCRITP_PATH', 'http://www.staticdomainname.com/wp-content/themes/Boutique/js/default.js');

    Then call the script like this -

    wp_enqueue_script('sn-default', 'MY_SCRITP_PATH', array('jquery'));

  3. Richard K
    Posted 4 years ago #

    Hello Duck boy,
    Thanks for your quick reply.

    The problem with this is that I'd need to change the files in my external plugins, which will be overwritten with an update for those plugins.

Topic Closed

This topic has been closed to new replies.

About this Topic