Viewing 15 replies - 1 through 15 (of 16 total)
  • The <head> tags typically should only be in header.php.

    Thread Starter mihaipopa

    (@mihaipopa)

    Yes. but I need to add a script in thankyou.php head. But I don’t have head in thankyou.

    The way WordPress functions is that there is a header.php to load the header for all pages. This makes it easier to edit the header since it is in one place. Thus, you can add the script to the header.php, but use conditionals to see if it is the thankyou page and if it is then load the script.

    Perhaps it would also help if you reviewed the template hierarchy in Theme Development?

    Thread Starter mihaipopa

    (@mihaipopa)

    respectyoda can you show me a example please?

    I think will be something linke this

    if page is (thankyou.php)
    my script

    if( is_page( 'order-received' ) ) {
      // statements
    }

    Means do < statements > when the page with the slug of “order-received” is being displayed.

    More options here.

    Thread Starter mihaipopa

    (@mihaipopa)

    If I try to add your code or this kind of cod in head.php :
    <?php
    if ( is_page(‘about’) || is_page(‘contact’)) {
    echo ‘<div id=”secondnav”>This is the super cool secondary navigation.</div>’;
    }
    ?>

    The website will stop working and I get only a blank white page.

    Ensure there is only one “<?php” on the first line of the file, and no “?>”s.

    Thread Starter mihaipopa

    (@mihaipopa)

    Sorry I can’t understand what you try to tell me.

    This is my javascript i need to be implemented in thankyou.php page but this page don’t have <head>.The only file where I found is on header.php.

    1.Copy and paste the following code between <head> and </head> on the page of your website on which you want to track actions. For example, to track registrations, place the code on your ‘registration completed’ web page.
    <script type=”text/javascript”>
    var fb_param = {};
    fb_param.pixel_id = ‘XXXXXXXXXX’;

    fb_param.value = ‘0.00’;
    fb_param.currency = ‘USD’;
    (function(){
    var fpw = document.createElement(‘script’);
    fpw.async = true;
    fpw.src = ‘//connect.facebook.net/en_US/fp.js’;
    var ref = document.getElementsByTagName(‘script’)[0];
    ref.parentNode.insertBefore(fpw, ref);
    })();
    </script>
    <noscript><img height=”1″ width=”1″ alt=”” style=”display:none” src=”https://www.facebook.com/offsite_event.php?id=6016044956826&value=0&currency=USD&#8221; /></noscript>

    You have to either use the slug or the ID of the thankyou.php page in the conditional. So go to header.php and locate the <head> tags. Within the <head> tags, do this.

    <?php if ( is_page('slug') ){ ?>
        //put the script code here
    <?php } ?>

    Once again, either use the slug or the ID of the page.

    Hi, The full javascript comes later. The first task is to get something working on the thank you page only. So put this in header.php :

    if( is_page( 'order-received' ) ) {
      echo '<script type="text/javascript">alert("Hello");</script>';
    }

    Do not use <?php because there will be one of these tags already at the top of the page.

    Do not use ?>

    You should get an alert box on the thank you page only. Does this work for you?

    Iorro, <?php may need to be used if it is closed by a ?> before the <head> tags. At this juncture, we don’t know if this is the case or not.

    Thread Starter mihaipopa

    (@mihaipopa)

    My ID for order complete page is 9.

    <?php if ( is_page(‘9’) ){ ?>
    //put the script code here
    <?php } ?>

    If one is using an ID then don’t use quote marks. Quote marks are only to be used with a slug. I should have mentioned that earlier.

    So…

    <?php if ( is_page(9) ){ ?>
       <script type="text/javascript">
    var fb_param = {};
    fb_param.pixel_id = 'XXXXXXXXXX';
    
    fb_param.value = '0.00';
    fb_param.currency = 'USD';
    (function(){
    var fpw = document.createElement('script');
    fpw.async = true;
    fpw.src = '//connect.facebook.net/en_US/fp.js';
    var ref = document.getElementsByTagName('script')[0];
    ref.parentNode.insertBefore(fpw, ref);
    })();
    </script>
    <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=6016044956826&value=0&currency=USD" /></noscript>
    <?php } ?>
    Thread Starter mihaipopa

    (@mihaipopa)

    respectyoda thanks very much.Now is working good.I hope facebook will activate now statistics for website.Again thanks very much.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘thankyou.php script’ is closed to new replies.