The MU forums have moved to WordPress.org

Add a chunk of code under the header? (3 posts)

  1. EricDealers
    Member
    Posted 13 years ago #

    I'm looking to add a unique chunk of html between the header and the body of any blog based on 1 theme. Like so:
    --------

    THEME HEADER
    <- Unique, blog-wide chunk of html code
    THEME BODY

    THEME FOOTER

    ----------

    A proper site-wide subhead as it were.

    There are a few 'custom header' or 'custom subhead' plugins that allow for text plugins on a post/page basis. No good.

    I've also tested a handful of 'custom header + footer' plugins, but the header additions either come in before <?php get_header(); ?>, or they focus on meta data adds, etc.

    I've also tried a few ad-serving plugins, but they tend to work with absolute/specific paths to ad repositories (ie, plug in ad set #4748239472 for every blog generated from X Theme) instead of a relative/generic path (ie, plug in the 'Subhead' ad for this specific blog).

    I'd love to find something that allows for a generic php tag to live under the get_header tag in the theme files...and then gets populated on a blog-by-blog basis via the wp-admin interface if possible.

    Thoughts? Thanks!

  2. dsader
    Member
    Posted 13 years ago #

    Specifically, wp_footer is an action hook present in most(all) themes from wordpress theme repository.

    So you could create your plugin file and keep it in mu-plugins:

    <?php function  my_advert() {
    echo 'Click Me! Buy Me!';
    }
    add_action( 'wp_footer', 'my_advert' );
    ?>

    (I'd echo output from the wp_footer hook and add css to the wp_head hook)

    Of course you can create your own template tag and add it to all/any themes wherever you like.
    <?php my_advert(); ?>

  3. EricDealers
    Member
    Posted 13 years ago #

    Thanks for the input. My PHP hand isn't strong, but your example looks feasible enough.

    That said, I was just coming back to post that the Dynamic Headers by Nicasio Design plugin seems to do the trick for my particular/relatively simple situation.
    http://nicasiodesign.com/blog/category/wordpress-plugins/

    I'll try post some urls for my implementation once I get some final-ish examples together.

    Thanks again!

About this Topic

  • Started 13 years ago by EricDealers
  • Latest reply from EricDealers