Title: wp_speculation_rules_href_exclude_paths
Published: February 24, 2026
Last modified: August 20, 2026

---

# apply_filters( ‘wp_speculation_rules_href_exclude_paths’, string[] $href_exclude_paths, string $mode )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#user-contributed-notes)

Filters the paths for which speculative loading should be disabled.

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

All paths should start in a forward slash, relative to the root document. The `*`
can be used as a wildcard.
If the WordPress site is in a subdirectory, the exclude
paths will automatically be prefixed as necessary.

Note that WordPress always excludes certain path patterns such as `/wp-login.php`
and `/wp-admin/*`, and those cannot be modified using the filter.

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

 `$href_exclude_paths`string[]

Additional path patterns to disable speculative loading for.

`$mode`string

Mode used to apply speculative loading. Either `'prefetch'` or `'prerender'`.

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

    ```php
    $href_exclude_paths = (array) apply_filters( 'wp_speculation_rules_href_exclude_paths', array(), $mode );
    ```

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

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

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

Returns the full speculation rules data based on the configuration.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/?output_format=md#comment-content-7580)
 2.   [Ahmed Elgameel](https://profiles.wordpress.org/elgameel/)  [  3 months ago  ](https://developer.wordpress.org/reference/hooks/wp_speculation_rules_href_exclude_paths/#comment-7580)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_speculation_rules_href_exclude_paths%2F%23comment-7580)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_speculation_rules_href_exclude_paths%2F%23comment-7580)
 4. **Note:** All paths must start with a forward slash and are evaluated relative 
    to the root document. The asterisk **(\*)** can be used as a wildcard.
 5. Example: The following code ensures that any URL starting with /go/ (e.g. ‘_example.
    com/go/wp1234/_‘) is completely excluded from speculative loading rules:
     ` add_filter('
    wp_speculation_rules_href_exclude_paths', function( $href_exclude_paths ) {$href_exclude_paths[]
    = '/go/*'; return $href_exclude_paths; });
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_speculation_rules_href_exclude_paths%2F%3Freplytocom%3D7580%23feedback-editor-7580)

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