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

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


Description Description


Parameters Parameters

$headers

(string[]) Associative array of headers to be sent.

$this

(WP) Current WordPress environment instance.


Top ↑

Source Source

File: wp-includes/class-wp.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Nick Cernis

    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.