# Keep Elementor Templates Out of Search Engines

> Sends visitors who open a saved Elementor template's own address back to the homepage and marks those pages noindex, so loose template URLs never show up in Google.

- Type: PHP
- Runs: Frontend only
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: elementor, seo, templates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/elementor-library-private/

## Code

```php
add_action( 'template_redirect', function () {
    if ( ! is_singular( 'elementor_library' ) || current_user_can( 'edit_posts' ) ) {
        return;
    }

    if ( isset( $_GET['elementor-preview'] ) || isset( $_GET['preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
        return;
    }

    wp_safe_redirect( home_url( '/' ), 301 );
    exit;
} );

add_filter( 'wp_robots', function ( $robots ) {
    if ( is_singular( 'elementor_library' ) ) {
        $robots['noindex']  = true;
        $robots['nofollow'] = true;
    }

    return $robots;
} );
```

## Notes

Logged-in editors and Elementor previews are not redirected.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Elementor Templates Out of Search Engines" 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/
