WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Richard K
    Member
    Posted 2 years ago #

    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:

    http://www.dynamicdomainname.com/wp-content/themes/Boutique/js/default.js?ver=3.2.1

    But we want it to be:

    http://www.staticdomainname.com/wp-content/themes/Boutique/js/default.js?ver=3.2.1

    How can we set this default?

  2. duck__boy
    Member
    Posted 2 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
    Member
    Posted 2 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