Title: wp_is_internal_link
Published: March 29, 2023
Last modified: May 20, 2026

---

# wp_is_internal_link( string $link ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#wp--skip-link--target)

Determines whether or not the specified URL is of a host included in the internal
hosts list.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#see-also)󠁿

 * [wp_internal_hosts()](https://developer.wordpress.org/reference/functions/wp_internal_hosts/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#parameters)󠁿

 `$link`stringrequired

The URL to test.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#return)󠁿

 bool Returns true for internal URLs and false for all other URLs.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#source)󠁿

    ```php
    function wp_is_internal_link( $link ) {
    	$link = strtolower( $link );
    	if ( in_array( wp_parse_url( $link, PHP_URL_SCHEME ), wp_allowed_protocols(), true ) ) {
    		return in_array( wp_parse_url( $link, PHP_URL_HOST ), wp_internal_hosts(), true );
    	}
    	return false;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/link-template.php#L4898)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/link-template.php#L4898-L4904)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_internal_hosts()](https://developer.wordpress.org/reference/functions/wp_internal_hosts/)`wp-includes/link-template.php` |

Returns an array of URL hosts which are considered to be internal hosts.

  | 
| [wp_parse_url()](https://developer.wordpress.org/reference/functions/wp_parse_url/)`wp-includes/http.php` |

A wrapper for PHP’s parse_url() function that handles consistency in the return values across PHP versions.

  | 
| [wp_allowed_protocols()](https://developer.wordpress.org/reference/functions/wp_allowed_protocols/)`wp-includes/functions.php` |

Retrieves a list of protocols to allow in HTML attributes.

  |

| Used by | Description | 
| [_make_clickable_rel_attr()](https://developer.wordpress.org/reference/functions/_make_clickable_rel_attr/)`wp-includes/formatting.php` |

Helper function used to build the “rel” attribute for a URL when creating an anchor using [make_clickable()](https://developer.wordpress.org/reference/functions/make_clickable/) .

  | 
| [wp_rel_callback()](https://developer.wordpress.org/reference/functions/wp_rel_callback/)`wp-includes/formatting.php` |

Callback to add a rel attribute to HTML A element.

  | 
| [get_comment_author_link()](https://developer.wordpress.org/reference/functions/get_comment_author_link/)`wp-includes/comment-template.php` |

Retrieves the HTML link to the URL of the author of the current comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_is_internal_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.2.0](https://developer.wordpress.org/reference/since/6.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_is_internal_link%2F)
before being able to contribute a note or feedback.