SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Different CSS styles for different pages

    For some reason on the Register/Login page for my site the logo gets pushed up a few inches but only on those two pages. I already have the #logo defined in the css so if I change it to accommodate the Register/Login page it won't be in the right position on other pages. Basically what I need to do is have a different margin-top set for the logo on the Register and Login page. But everything I've tried has returned errors (like using the <body id=" "> tag then calling that in the CSS).

    Any advice?

    Thanks.

  2. #2
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    One way is to create a new function in /wp-content/my_theme/functions.php like so:

    PHP Code:
    function push_logo() 
    {
    echo 
    '<style type="text/css">#logo {margin-top: 10px !important; }</style>';
    }

    add_action('login_head''push_logo'); 
    Maleika E. A. | Rockatee | Twitter | Dribbble



  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,167
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Maybe another way to add a special class to the body tag would be to do something like this in your template:

    PHP Code:
    <?php
    $url 
    = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 

    if (
    $url == 'http://mysite.com/register.php' || $url == 'http://mysite.com/login.php') {
    echo 
    '<body class="specialclass">'; } else {
    echo 
    '<body>';
    }
    ?>
    Just replace the <body> tag with the code above, changing the urls to the urls of the pages in question.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestions - tried both but oddly neither worked. The one thing that fixes the problem causes a bigger problem. Adding
    PHP Code:
    echo '<style type="text/css">#logo {margin-top: 9px !important; }</style>'
    To the top of wp-login.php aligns the logo properly, but when you fill in your username/pass and click submit it doesn't redirect you. It just leaves you on a blank page. So I am completely stumped on this one, from what I've seen, adding ANYTHING to wp-login.php messes something up.

  5. #5
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    Luxe, I've tested the code I posted on my testserver and it works 100%. How have you implemented the code?
    Maleika E. A. | Rockatee | Twitter | Dribbble



  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kohoutek View Post
    Luxe, I've tested the code I posted on my testserver and it works 100%. How have you implemented the code?
    I just copied and pasted the code into my WP functions file.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •