WordPress filter hook · part of WordPress core

site_url

A WordPress core filter that 11 plugins also fire themselves, running on 133K+ sites between them.

“Filters the site URL.”

How to use site_url

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'site_url', function( $url, $path, $orig_scheme ) {
	// Change $url here.
	return $url;
}, 10, 3 );

Argument names come from WP JW Player's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

11 plugins that fire site_url

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Defender Security icon Defender Security80,000+ installs apply_filters( 'site_url', $url, $path, $scheme, $blog_id ) src/controller/class-mask-login.php:623
  2. SecuPress with Simple SSL icon SecuPress with Simple SSL40,000+ installs apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null ) free/functions/common.php:2548
  3. SP Move Login icon SP Move Login6,000+ installs apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null ) free/functions/common.php:1743
  4. Themify Builder icon Themify Builder6,000+ installs apply_filters( 'site_url', get_option('siteurl'), '', null, null ) themify/cache/class-themify-cache.php:555
  5. Parse.ly icon Parse.ly1,000+ installs apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null ) src/Utils/class-utils.php:416
  6. WP JW Player icon WP JW Player60+ installs apply_filters( 'site_url', $url, $path, $orig_scheme ) plugin.php:212
  7. Sniplets icon Sniplets30+ installs apply_filters( 'site_url', $url, $path, $orig_scheme ) plugin.php:211
  8. Filled In icon Filled In20+ installs apply_filters( 'site_url', $url, $path, $orig_scheme ) plugin.php:215
  9. DragDropr icon DragDropr10+ installs apply_filters( 'site_url', $url, $path, $scheme, $blog_id ) lib/ddr-class-wp-rest-oauth1-admin.php:376
  10. ICanLocalize Translator icon ICanLocalize Translator10+ installs apply_filters( 'site_url', $url, $path, $orig_scheme ) inc/rpc-functions.php:288
  11. UBB Master icon UBB MasterFewer than 10 installs apply_filters( 'site_url', $url, $path, $orig_scheme ) base/search-plugin.php:212

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.