# Remove WPML hreflang Tags From Paginated and Filtered Pages

> Stops WPML from printing hreflang tags on page 2+ of archives, search results and URLs with query strings, where the alternates often point at mismatched pages.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: wpml, hreflang, seo
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpml-hreflang-skip-paged/

## Code

```php
add_filter( 'wpml_hreflangs', function ( $hreflangs ) {
    if ( is_paged() || is_search() || ( ! empty( $_GET ) && ! is_singular() ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        return array();
    }

    return $hreflangs;
} );
```

## Notes

The first page of each archive and every singular page keep their hreflang tags.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove WPML hreflang Tags From Paginated and Filtered Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
