The MU forums have moved to WordPress.org

Including code on all pages of all blogs? (4 posts)

  1. fogster
    Member
    Posted 15 years ago #

    I'd like to include some JavaScript tracking code on every page served up, across multiple blogs. Right now it's just a bit of JavaScript (for Google Analytics), though I might be interested in including some PHP logic at some point.

    Is there a way I can cause this to happen globally on a WPMU installation? I'm not sure if a simple plugin would work, as it'd still have to be enabled per blog.

  2. fogster
    Member
    Posted 15 years ago #

    (FWIW, after hitting post here, I got a "Topic not found" error, but it obviously posted anyway)

  3. andrea_r
    Moderator
    Posted 15 years ago #

    A simple plugin is exactly how it works, and you hook in the wp_footer call, which shows up in pretty much every theme.

    http://wpmututorials.com/plugins/how-to-hook-into-the-footer/

  4. my-gude_org
    Member
    Posted 15 years ago #

    that's very simple.
    first you need a hook:

    add_action('wp_footer', 'my_function', 10);

    Now, you have do define your function:
    function my_function() {
    //...
    echo "Hello To All Blogs!
    ";
    //...
    }

    Have fun!

About this Topic

  • Started 15 years ago by fogster
  • Latest reply from my-gude_org