• Hi. I created a page-template which seems to be working fine. I wanted to try adding some meta gags on the page. After reading about how it’s been on this site I tried myself. Here’s the code that I put in my header.php file:

    <?php if(is_page(4)) {?>
    <meta name=”description” content=”Description of the page”/>
    <meta name=”keywords” content=”a list, of, my, keywords”/>
    <?php }?>
    <?php wp_head(); ?>

    …When I use “View Source” for the page I don’t see the meta tag. What could I be doing wrong? Thanks for any help with this one!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,
    Your code looks fine to me. Are you sure the ID of the page is 4? By the way, is_page() function also accepts page slug or title, so you can use is_page( 'Your Page Title' ) too, maybe that is easier.
    Hope that helps.

    Thread Starter RedChill

    (@redchill)

    Sorry for replying so late. Page 4 is not one of my page id. Just using it as an example. My site is here: https://www.davidsdrift.com/food/. Now I CAN! see them on when I go to “View Source”.

    Don’t know why I didn’t a month ago. Anyway, thank you very much for your confirmation!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I tried adding meta tags to my header file and it's not working. Please help!’ is closed to new replies.