The MU forums have moved to WordPress.org

Global Header (9 posts)

  1. mikeboy3
    Member
    Posted 15 years ago #

    Greetings,
    I need to have a Myspace-like header on all pages and all blogs, I tried doing it by modifying the Admin-Bar plugin and adding the cde, but I was wondering if there is a way to do it with a mu-plugin file. I dropped the header code into the mu-plugin folder and it loaded, of course, it broke the admin interface, so, what code can be used to limit the load of a code to blog pages?

    this is the code Im using:

    <style type="text/css">
    .tfheader {
    width: 955px;
    height: 100px;
    background:#906;
    margin-top: 20px;
    margin-left:auto;
    margin-right:auto;
    text-align: left;
    }
    </style>

    <div class="tfheader">
    <img src="http://tanfemenina.com/Portals/1/Skins/tanfemenina/images/tf_header_main_01.jpg"> Hola como estas!
    </div>

    This code is in a file called "tfheader.php" and it should be uploaded to the wpcontent/mu-plugins directory and just work.

    How can I include this file to the Admin-Bar plugin? I am trying to add this after the bar's code:
    include '/wp-content/mu-plugins/tfheader/tfheader.php'

    any ideas? any other simpler ways to do this?

    thanks in advance

  2. andrea_r
    Moderator
    Posted 15 years ago #

    hook in wp-footer, which is only on the front end, included in most themes. :)

  3. mikeboy3
    Member
    Posted 15 years ago #

    thank you for your reply, but I didn't quite understand it, what does that mean? How would I do that?

    EDIT:

    I created this .php file:

    <?php

    function tfheader() {

    echo '<div class="tfheader">';
    echo '<img src="http://tanfemenina.com/Portals/1/Skins/tanfemenina/images/tf_header_main_01.jpg"> Hola como estas!';
    echo '</div>';

    }
    ?>

    <style type="text/css">

    body {
    padding-top: 120px !important;
    }

    .tfheader {
    width: 955px;
    height: 100px;
    background:#906;
    margin-top: 20px;
    margin-left:auto;
    margin-right:auto;
    text-align: left;
    }

    </style>

    <?php
    add_action('wp_footer', 'tfheader');
    ?>

    It works, sort of, I now have to get the CSS to work and place the code at the top, but at least I got it to display!
    Thanks.

    I tried this:

    <?php

    function tfheader() {

    echo '<div class="tfheader">';
    echo '<img src="http://tanfemenina.com/Portals/1/Skins/tanfemenina/images/tf_header_main_01.jpg"> Hola como estas!';
    echo '</div>';
    echo '<style type="text/css">';
    echo 'body {'
    echo 'padding-top: 148px !important; ';
    echo '}';
    echo '.tfheader {';
    echo ' width: 955px;';
    echo ' height: 100px;';
    echo ' background:#906;';
    echo ' margin-top: -100px;';
    echo ' margin-left:auto;';
    echo ' margin-right:auto;';
    echo ' text-align: left;';
    echo '}';
    echo '</style>';
    }
    ?>

    <?php
    add_action('wp_footer', 'tfheader');
    ?>

    It broke all my pages

    The thing I see is that the CSS style that works, (the first code) is loaded before the <html> tag, and it breaks the CSS for the admin pages. How do define CSS that will only load with the wp_footer()?

  4. mikeboy3
    Member
    Posted 15 years ago #

    Ok, I got it to work, I figured it out, thank you very much andrea_r, this is the code I used:

    <?php

    function tfheader() {

    echo '<div class="tfheader">';
    echo '<img src="http://tanfemenina.com/Portals/1/Skins/tanfemenina/images/tf_header_main_01.jpg"> Hola como estas!';
    echo '</div>';
    }

    function tfheader_style() { ?>
    <style type="text/css">

    body {
    padding-top: 148px !important;
    }

    .tfheader {
    width: 955px;
    height: 100px;
    background:#906;
    margin-top: -100px;
    margin-left:auto;
    margin-right:auto;
    text-align: left;
    }

    </style>

    <? }

    add_action('wp_footer', 'tfheader');
    add_action('wp_head','tfheader_style');
    ?>

  5. tdjcbe
    Member
    Posted 15 years ago #

    Suggestion: Please don't paste code here to the forums. Please use a service like pastebin or copy it to a txt file and link to it. The forums don't handle code that well.

    Required reading linked to from the readme file:

    http://codex.wordpress.org/Debugging_WPMU

  6. mikeboy3
    Member
    Posted 15 years ago #

    oh, ok, sorry about that, will do next time :)

  7. mikeboy3
    Member
    Posted 15 years ago #

    I just discovered a problem with this code, now, in order to access a blog, you need to add a / at the end

    Example:
    no good - http://tanfemenina.iamzaks.com/maria
    good - http://tanfemenina.iamzaks.com/maria/

    why does this happen? I checked and the problem comes when this file is in the mu-plugins folder.

    here it is: http://pastebin.com/m5868efe7

  8. mikeboy3
    Member
    Posted 15 years ago #

    Please, this is a big problem, hopefully the last one for this little piece of code

  9. mikeboy3
    Member
    Posted 15 years ago #

    I kept on looking at the code, I don't know what else to do.

About this Topic

  • Started 15 years ago by mikeboy3
  • Latest reply from mikeboy3