Wordpress- How to insert code to header for a specific page only?

header, php, themes, wordpress

Solution

you have to just add your pageid on your header file like this

global $post;
if($post->post_type == 'page' && $post->ID == page_int){
   echo '<meta name="robots" content="noindex, nofollow" />';
}

it will just display meta on specific page which you want.

Suppose you only want to output the code for the page with ID = 5, set `page_int` to `5`. This is an integer, so do not use single quotes around it.

Problem

I use wordpress and would like to add 2 lines of code to the header of one page only. The problem is that header.php will change all the site's headers and I want it to change only the header of one specific page. The only thing I want to do is add this 1 line : ``` <META name="robots" content="noindex, nofollow"/> ```

Original source