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

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

Parameters

$headersstring[]
Associative array of headers to be sent.
$wpWP
Current WordPress environment instance.

Source

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

Changelog

VersionDescription
2.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    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: http://reference.sitepoint.com/html/meta/http-equiv

    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.