Support » Fixing WordPress » Changing the default url/file path for wp_enqueue

  • Hi,
    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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', '');

    Then call the script like this –

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

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing the default url/file path for wp_enqueue’ is closed to new replies.