Support » Fixing WordPress » Function not attaching to wp_footer hook

  • I’m having some issues getting this functionality to work. It must be something I’m overlooking. This is my code:

    if ( is_page_template('template-thankyou.php') ) {
        function eh_add_product_tracking_code(){
            $meta_key = 'product_code';
            $meta_value = get_post_meta($post->ID, $meta_key, true);
            return $meta_value;
        add_action('wp_footer', 'eh_add_product_tracking_code');

    Basically, I’m trying to add a custom field named product_code to the footer of the template-thankyou.php page from the functions.php.

    As you can see, I check to see if we are on a page using the correct template. Then I use a function to get the custom field text and return it. Then I add it to the footer.

    The footer shows nothing. Any ideas?

Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Function not attaching to wp_footer hook’ is closed to new replies.