Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"/>
like image 291
david Avatar asked May 03 '13 07:05

david


1 Answers

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.

like image 160
kuldip Makadiya Avatar answered Oct 31 '22 02:10

kuldip Makadiya