Inserting Code after

Community Forums Forums General Discussion Inserting Code after

This topic is: not resolved

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  rfmeier 1 year, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #44245

    gwoodard
    Participant

    Good evening all. I am working on monetizing my blog & I need to add some code after the <body> tag. I am running the Balanced Child Theme on the Genesis Framework. The code I need to add is below. I would appreciate assistance on where I go to add the code.

    Thanks!

    <!-- Beacon Ads Ad Code -->
    <script type="text/javascript">
    (function(){
      var bsa = document.createElement('script');
         bsa.type = 'text/javascript';
         bsa.async = true;
         bsa.src = 'http://cdn.beaconads.com/ac/beaconads.js';
      (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
    })();
    </script>
    <!-- End Beacon Ads Ad Code -->
    
    
    http://www.gregorywoodard.com
    #44246

    rfmeier
    Participant

    You can hook the WordPress ‘wp_footer’ action and print your script there.

    add_action( &#8216;wp_footer&#8217;, &#8216;custom_wp_footer&#8217; );
    /**
     * Callback for WordPress &#8216;wp_footer&#8217; action.
     * 
     * Print javascript before the end of &lt;/body&gt;
     * 
     * @package WordPress
     * @category Footer script
     * @author Ryan Meier <a href="http://www.rfmeier.net" rel="nofollow">http://www.rfmeier.net</a>
     */
    function custom_wp_footer(){
            
            echo &quot;&lt;!&#8211; Beacon Ads Ad Code &#8211;&gt;
                    &lt;script type=&#8217;text/javascript&#8217;&gt;
                    (function(){
                      var bsa = document.createElement(&#8216;script&#8217;);
                         bsa.type = &#8216;text/javascript';
                         bsa.async = true;
                         bsa.src = &#8216;http://cdn.beaconads.com/ac/beaconads.js';
                      (document.getElementsByTagName(&#8216;head&#8217;)[0]||document.getElementsByTagName(&#8216;body&#8217;)[0]).appendChild(bsa);
                    })();
                    &lt;/script&gt;
                    &lt;!&#8211; End Beacon Ads Ad Code &#8211;&gt;&quot;;
            
    }

    I hope this helps.


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

You must be logged in to reply to this topic.