1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can anyone help insert code in only 1 wp page header

Discussion in 'Blogging' started by boro, May 9, 2009.

  1. boro

    boro Regular Member Premium Member

    Joined:
    Aug 6, 2008
    Messages:
    264
    Likes Received:
    161
    Hi can someone tell me how to insert some code into the head code of just 1 page of a wordpress site ? I asked this in the cpa section as that is what it is about but no answers so far.
    So hopefully some wordpress expert can help me out as I have got nowhere with google.
    If no one comes up with an answer my only option is original wp site with link to new wp site (rather than a page on original) with code in that header :(
    Cheers
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    PHP:
    <?php
    if (is_page('42') ){//here your code}
    ?>
    Change 42 - to any ID of your page
     
  3. boro

    boro Regular Member Premium Member

    Joined:
    Aug 6, 2008
    Messages:
    264
    Likes Received:
    161
    Thanks for the reply but I need a bit more help :dunce:
    so I insert that code in the header

    and this '42' would be the title of my page as that is how I have it set up as in www.headache.com/more-pain-relief

    and {//here your code} // are needed yes I am guessing you have not got twitchy fingers on the keyboard

    So {//<script src blah blah blah }

    Thanks again
     
  4. boro

    boro Regular Member Premium Member

    Joined:
    Aug 6, 2008
    Messages:
    264
    Likes Received:
    161
    just seems to keep giving me errors
     
  5. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Look in the theme folder for the theme you are using and but the code above in the header.php file.

    When the header is loaded it will check if its the correct page to run the rest of the code otherwise it does nothing.

    I am guessing is_page is a WP function - you can do it in pure PHP as well.

    Just change '42' to 'more-pain-relief' and it should be good to go I think.
     
    • Thanks Thanks x 1
  6. boro

    boro Regular Member Premium Member

    Joined:
    Aug 6, 2008
    Messages:
    264
    Likes Received:
    161
    yes have put it in the header in theme editor but it gives errors will put it back in and see what error actually is
    Parse error: syntax error, unexpected $end in /home/*****/public_html/*******/wp-content/themes/flexsqueeze/header.php on line 96
     
  7. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Feel free to send me the header.php file and I will put the line in for you.
    Never used the theme editor, normally just edit the files direct :)

    Grab me on MSN, ID in profile
     
  8. boro

    boro Regular Member Premium Member

    Joined:
    Aug 6, 2008
    Messages:
    264
    Likes Received:
    161
    Cheers just sent it as a a pm