• Hello guys,

    So I want to insert Facebook Tracking Pixel code to <head> tag of my website. Plus additionally I want different version of the code to be inserted in one specific page.
    So here’s what I did:

    1. created two functions in functions.php (function_1 , function_2) inserting adequate code to each.
    2. put this into header.php:

    <?php 
    if ( is_page(123) ) {
    	function_1();
    }
     else {
    	function_2();
    }
    ?> 

    Now the problem: no matter if I’m on the page ‘123’ or any other page, in the <head> section I see both codes inserted. From function_1 and right after that function_2.

    What might be wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi fater
    Hope you are doing good today 🙂
    Can you pass the id as a string in function like this:
    if ( is_page('123') )
    Maybe it will work. 🙂

    Hello,

    Could you send the complete code of your functions to understand why you get both code inserted.

    Your code seems to be Ok but I can chek it with you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with is_page in header.php’ is closed to new replies.