apply_filters( 'wp_headers', string[] $headers, WP $wp )

Filters the HTTP headers before they’re sent to the browser.


$headers string[]
Associative array of headers to be sent.
$wp WP
Current WordPress environment instance.

Top ↑


File: wp-includes/class-wp.php. View all references

$headers = apply_filters( 'wp_headers', $headers, $this );

Top ↑


Version Description
2.8.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Nick C

    This filter won’t allow you to modify headers if your site serves cached pages via a plugin or third-party caching system. The cached page will be served before your wp_headers are filtered.

    You may be able to add an HTML meta tag with the http-equiv attribute using wp_head() to work around this for certain headers:

    function gnu_terry_pratchett_meta() {
        if ( WP_CACHE ) {
            echo '<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />';
    add_action( 'wp_head', 'gnu_terry_pratchett_meta' );

    Alternatively, explore setting headers at the server level with .htaccess or similar if you can.

    header set X-Clacks-Overhead "GNU Terry Pratchett"

You must log in before being able to contribute a note or feedback.