Using Custom Fields in Footer (2 posts)

  1. madmaxcap
    Posted 6 years ago #

    I'm trying to find a creative solution to a problem I've got and need your generous help :D

    I've got a tracking script which I've got in my footer.php before the </body> tag. The problem is, each script is different for each page.

    Here's an example:

    <script src="http://www.gotomerchant.com/tracking202/static/landing.php?lpip=946" type="text/javascript"></script>

    The '946' is manually generated elsewhere from the Tracking software.

    For simplicity I want to be able to use a Custom Field to store this number. Then have something like the following in the footer to generate it:

    function tracking_stuff() {
    if (is_single() || is_page()) {
    echo '<script src="http://www.gotomerchant.com/tracking202/static/landing.php?lpip=';
    <<<<<<TRACKING NUMBER HERE>>>>>>>>();
    echo '" type="text/javascript"></script>';
    add_action('thesis_hook_after_html', 'tracking_stuff');

    The only challenge is that because the footer is outside the loop, I am having issues calling the tracking number.

    The above is a bit hacky but I'm only a beginner at PHP, does anybody know how to call Fields from outside the loop?

    Would appreciate your help :D

  2. Sarah Gooding
    Posted 6 years ago #

    You can call in a custom footer for each script on each page by using custom fields. Check out a quick tutorial here. I think you'll find it quite simple to create custom footers for each of your scripts:


Topic Closed

This topic has been closed to new replies.

About this Topic