Forums

Adding custom code to all blogs on MU (8 posts)

  1. synackSA
    Member
    Posted 1 month ago #

    Hi there

    Is it possible to add custom code to all blogs accross MU, no matter what theme they are using? I need to add tracking code to all blogs on a MU system, this is custom tracking code and usually, I've just gone an added one include line in the footer.php, but it's always been on a single user system.

    Is this possible?

    Syn

  2. SteveAtty
    Member
    Posted 1 month ago #

    If you know they have a footer then you can use the code snippet I posted the other day.

    OR you can push it into the header by dropping a file into mu-plugins which contains something like:

    <?php
    
    function wpmu_header($blah){;
    echo '<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAzDaUChkNH3lPjAjJapKq6RTvY22eKy7N0CiFH2Ct6wY8stwoVxR4QHlGjqnhLQYhV02RACCBlloxaA" type="text/javascript"></script>';
    echo '<meta name="verify-v1" content="gh8YjrQxNNQP2cet22ZdfXucI+py1YHC/6eczI1ljHc=" >';
    return $blah;
    }
    
    add_action('wp_head', 'wpmu_header');
    ?>
  3. andrea_r
    Member
    Posted 1 month ago #

    Yep, what Steve said. Hook into wp_head or wp_footer.

  4. synackSA
    Member
    Posted 1 month ago #

    Okay, if it's in mu-plugins, will it be a compulsary plugin for all the blogs, or could the blogs technically disable it?

  5. SteveAtty
    Member
    Posted 1 month ago #

    code in mu-plugins is run automatically, so it can't be deactivated, unless you wrote the code to allow it to be turned off

  6. synackSA
    Member
    Posted 1 month ago #

    Awesome, thanks.

  7. wpmuguru
    Member
    Posted 4 weeks ago #

    If it doesn't show up on some blogs, check the footer.php in that theme to see if it calls wp_footer();

  8. SteveAtty
    Member
    Posted 4 weeks ago #

    Which is why I suggested the alternative of putting it in the header ;-)

Reply

You must log in to post.

About this Topic