Title: pre_get_network_by_path
Published: April 25, 2014
Last modified: May 20, 2026

---

# apply_filters( ‘pre_get_network_by_path’, null|false|WP_Network $network, string $domain, string $path, int|null $segments, string[] $paths )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/pre_get_network_by_path/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_get_network_by_path/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_get_network_by_path/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_get_network_by_path/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_get_network_by_path/?output_format=md#changelog)

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

Determines a network by its domain and path.

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

This allows one to short-circuit the default logic, perhaps by replacing it with
a routine that is more optimal for your setup.

Return null to avoid the short-circuit. Return false if no network can be found 
at the requested domain and path. Otherwise, return an object from [wp_get_network()](https://developer.wordpress.org/reference/functions/wp_get_network/).

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

 `$network`null|false|[WP_Network](https://developer.wordpress.org/reference/classes/wp_network/)

Network value to return by path. Default null to continue retrieving the network.

`$domain`string

The requested domain.

`$path`string

The requested path, in full.

`$segments`int|null

The suggested number of paths to consult.
 Default null, meaning the entire path
was to be consulted.

`$paths`string[]

Array of paths to search for, based on `$path` and `$segments`.

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

    ```php
    $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths );
    ```

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

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

| Used by | Description | 
| [WP_Network::get_by_path()](https://developer.wordpress.org/reference/classes/wp_network/get_by_path/)`wp-includes/class-wp-network.php` |

Retrieves the closest matching network for a domain and path.

  |

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

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

## User Contributed Notes

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