# Remove ?replytocom From Comment Reply Links

> Stops comment reply links from creating ?replytocom= URLs that crawlers treat as duplicate pages, and redirects any such URL to the clean post address.

- Type: PHP
- Runs: Frontend only
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: comments, duplicate-content, crawling
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/seo-remove-replytocom/

## Code

```php
add_filter( 'comment_reply_link', function ( $link ) {
    return preg_replace( '/href=([\'"])[^\'"]*replytocom=\d+[^\'"]*\1/', 'href="#respond"', $link );
} );

add_action( 'template_redirect', function () {
    if ( isset( $_GET['replytocom'] ) && is_singular() ) { // phpcs:ignore WordPress.Security.NonceVerification
        wp_safe_redirect( get_permalink( get_queried_object_id() ) . '#respond', 301 );
        exit;
    }
} );
```

## Notes

Replying still works through WordPress's comment-reply script, which every modern theme loads.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove ?replytocom From Comment Reply Links" 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/
