As an example: HTML5 Boilerplate provides an X-UA-Compatible meta element by default. This element breaks validation but can be moved to a header. Adding the following to functions.php fixes the validation issue and provides IE users a better experience.
As an example: HTML5 Boilerplate provides an X-UA-Compatible meta element by default. This element breaks validation, but can be moved to a header. Adding the following to functions.php fixes the validation issue and provides IE users a better experience.
Example of how to conditionally send a header, replacing previously set header, if any…
/**
* Send "X-Robots-Tag: noindex, nofollow" header if not a public web site.
* If WP_DEBUG is true, treat web site as if it is non-public.
*/
add_action( 'send_headers', function() {
if ( '0' != get_option( 'blog_public' ) || ( defined( 'WP_DEBUG' ) && true == WP_DEBUG ) ) {
/**
* Tell robots not to index or follow
* Set header replace parameter to true
*/
header( 'X-Robots-Tag: noindex, nofollow', true );
}
}, 99 ); // Try to execute last with priority set to 99
You must log in before being able to contribute a note or feedback.
Since WordPress 6.1, the send_headers action has been moved to later in core load. It is now triggered after pre_get_posts.
Conditionals tags can now be used (is_single, is_404 and so on).
More information on this dev-note: https://make.wordpress.org/core/2022/10/10/moving-the-send_headers-action-to-later-in-the-load/
As an example: HTML5 Boilerplate provides an X-UA-Compatible meta element by default. This element breaks validation but can be moved to a header. Adding the following to functions.php fixes the validation issue and provides IE users a better experience.
Example migrated from Codex:
As an example: HTML5 Boilerplate provides an X-UA-Compatible meta element by default. This element breaks validation, but can be moved to a header. Adding the following to functions.php fixes the validation issue and provides IE users a better experience.
Example of how to conditionally send a header, replacing previously set header, if any…