<span class="resolved" aria-label="Resolved" title="Topic is resolved."></span>Custom header from child theme

[ad_1]

Replies: 2

Hello,

I am trying to add a custom header using a filter from my child theme but it looks like the filter is not applied at all and redirection plugin directly handles the redirect.

The code I have is this:

function add_header_xrobots( $headers ) {
    if( !( stristr( $_SERVER['REQUEST_URI'], '/ulos/' ) === false ) )
        $headers['X-Robots-Tag'] = 'noindex, nofollow';

        return $headers;
}
add_filter( 'wp_headers', 'add_header_xrobots', 10, 2 );

May I ask you to tell me if there is an easy way to manipulate/add custom headers from inside the theme with a code?

Thank you in advance!

Kind regards,
Ali Nebi

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer