WordPress.org

Ready to get started?Download WordPress

Forums

Add different logo in each page (15 posts)

  1. nbhambra
    Member
    Posted 1 year ago #

    I'm trying to add different logos in header of each page but I don't know how to use page-id to get them to work.

    In CSS I have

    style.css:

    logo{
    float:left;
    }
    .logo a{
    width:240px;
    height:99px;
    display:block;
    background:url(images/main-logo.gif) no-repeat;
    margin-top:-4px;
    }
    .logo span{
    display:none;
    }

    Header.css:

    <div id="head">
    <div class="wrap">

    <div class="logo">
    /
    </div>
    </div>

    PLEASE HELP! Would really appreciate it :)

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    what theme are you using?
    does the theme use body_class() ?

    if yes:

    .page-id-23 .logo a { background: url(images/page-23-logo.gif) no-repeat; }

  3. nbhambra
    Member
    Posted 1 year ago #

    It custom theme and there is no body_class() in style.css

  4. Andrei Olsen
    Member
    Posted 1 year ago #

    Add body_class to your <body> HTML tag and you can style individual pages as mentioned above.

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    without body_class() you might need to use a lot of conditional statements in the head section of your theme;
    http://codex.wordpress.org/Function_Reference/is_page

    example:

    <style type="text/css">
    <?php if( is_page(23) ) { ?>
    .logo a { background: url(<?php echo get_stylesheet_directory_uri(); ?>/images/page-23-logo.gif) no-repeat; }
    <?php } elseif( is_page(77) ) { ?>
    .logo a { background: url(<?php echo get_stylesheet_directory_uri(); ?>/images/page-77-logo.gif) no-repeat; }
    <?php } ?>
    </style>

    http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

  6. nbhambra
    Member
    Posted 1 year ago #

    I just checked my header.css file and body_class is there in the body HTML tag but it's not working.

    Do I have to add the code in style.css or header.css?

    .page-id-23 .logo a { background: url(images/page-23-logo.gif) no-repeat; }

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    Do I have to add the code in style.css or header.css?

    this would go into style.css - obviously with the real page id in the code:

    .page-id-23 .logo a { background: url(images/page-23-logo.gif) no-repeat; }

  8. nbhambra
    Member
    Posted 1 year ago #

    I added the code in the style.css but it's not working

    .page-id-57 .logo a{
    width:240px;
    height:99px;
    display:block;
    background:url(images/siem-logo.jpg) no-repeat;
    margin-top:-4px;
    }
    .page-id-57 .logo span{
    display:none;
    }

  9. Andrew
    Forum Moderator
    Posted 1 year ago #

    What isn't working, any styling at all? Have you checked your stylesheet for syntax errors?

  10. nbhambra
    Member
    Posted 1 year ago #

    Still getting default logo and there is no errors in the syntax.

  11. Andrew
    Forum Moderator
    Posted 1 year ago #

    You need to give us more to go on, like a link to the webpage.

  12. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    where exactly have you added the new styles?

    there is no trace of that in style.css of the site linked with your username.

    also, the alternative logo image does not seem to be in its expected location.

  13. nbhambra
    Member
    Posted 1 year ago #

    The site is on my localhost. :(

  14. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    in this case, you are on your own with troubleshooting the styles :-(

    occasionally, stylesheets are broken because of missing brackets or whatever; in this case styles lower down in the stylesheet don't get applied.
    possibly, try moving the new style to the top of the stylesheet.

  15. Andrei Olsen
    Member
    Posted 1 year ago #

    Or you can upload your style.css and header.php to pastebin and give us a link.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags