wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_make_link_relative › WordPress Function

Since2.1.0
Deprecatedn/a
wp_make_link_relative ( $link )
Parameters:
  • (string) $link Full URL path.
    Required: Yes
Returns:
  • (string) Absolute path.
Defined at:
Codex:
Change Log:
  • 4.1.0

Converts full URL paths to absolute paths.

Removes the http or https protocols and the domain. Keeps the path '/' at the beginning, so it isn't a true relative link, but from the web root base.


Source

function wp_make_link_relative( $link ) {
	return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
}