# Disable Pingbacks and Trackbacks

> Closes pings on all content, removes the X-Pingback header and the XML-RPC pingback methods. Regular comments are not affected.

- Type: PHP
- Runs: Run everywhere
- Category: [Comments](https://wpide.com/library/category/comments/)
- Tags: comments, pingbacks, trackbacks, xml-rpc
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-pingbacks-trackbacks/

## Code

```php
add_filter( 'pings_open', '__return_false', 20 );

add_filter( 'wp_headers', function ( $headers ) {
    unset( $headers['X-Pingback'] );

    return $headers;
} );

add_filter( 'xmlrpc_methods', function ( $methods ) {
    unset( $methods['pingback.ping'], $methods['pingback.extensions.getPingbacks'] );

    return $methods;
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable Pingbacks and Trackbacks" 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/
