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

---

# apply_filters( ‘network_by_path_segments_count’, int|null $segments, string $domain, string $path )

## In this article

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

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

Filters the number of path segments to consider when searching for a site.

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

 `$segments`int|null

The number of path segments to consider. WordPress by default looks at one path 
segment. The function default of null only makes sense when you know the requested
path should match a network.

`$domain`string

The requested domain.

`$path`string

The requested path, in full.

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

    ```php
    $segments = apply_filters( 'network_by_path_segments_count', $segments, $domain, $path );
    ```

[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#L383)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-network.php#L383-L383)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/network_by_path_segments_count/?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/network_by_path_segments_count/?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%2Fnetwork_by_path_segments_count%2F)
before being able to contribute a note or feedback.