WordPress.org

Forums

Quark
[resolved] Have banner background/color be different on !is_front_page (9 posts)

  1. jcervantes28
    Member
    Posted 1 year ago #

    Hello,

    Is there a way to have the background/color of the banner be different on single posts, pages, etc. than on the home page? I like the color, but don't want it to expand the width it would normally take with 2 widgets embedded into it like in the home page.

    Thank you for your help and time,
    Jose

  2. Jesin A
    Member
    Posted 1 year ago #

    Use the code I've pasted in http://pastebin.com/m9XcbfAD

    Pasting it in the functions.php file will work but updating the theme will overwrite it. So create a child theme and paste the code in its functions.php file.

  3. jcervantes28
    Member
    Posted 1 year ago #

    Hello Jesin,

    Thank you for the help...it is pushing me along the right lines and I'm looking into it.

    The code you referenced did what I needed to do, except that it did it in the container that goes above the banner. I change the #headdercontainer to #bannercontainer, and while I think it works, the background attachment that is configured in the theme options takes precedence, I believe.

    So I am looking into the theme's function php at where it defines the background URL, I just don't know how to make it be my color I want, without the background, on !is_front_page.

    Let me know if that made sense. I appreciate your help.
    Jose

  4. Jesin A
    Member
    Posted 1 year ago #

    Hi Jose,

    Do you mean that some other CSS is overriding the style you've added?

    Can you post your site's URL for me to take a look.

  5. jcervantes28
    Member
    Posted 1 year ago #

    Might be CSS, not sure. But I know I see the URL being defined in functions.php, it probably refers to the background that we select through the theme's options.

    I didn't see the background URL in CSS, but it would make sense to be there.

    I want that background in home page, but when it is not a home page, I don't want a background within the banner. I simply want a color, like #0000FE.

    website is:
    http://www.shortstoryguy.com

    I want to customize the site more by adding my own colors, and that's one way I want to do it.

    Thank you,
    Jose

  6. Jesin A
    Member
    Posted 1 year ago #

    If you just do not want to display an image inside #bannercontent add this in the else part (line 13 of the pastebin link)

    background-image: none;

    If you don't want to display the #bannercontent itself use

    display: none;

    instead. Try both and use the one that suits you.

    Whatever you do just don't edit your functions.php file. All changes will be overridden if the theme is updated.

  7. jcervantes28
    Member
    Posted 1 year ago #

    Thank you Jesin!

    I did it with the following code:

    <?php
    function my_inline_styles()
    {
    ?>
    <style type="text/css">
    
    <?php if(is_front_page()): ?>
    #bannercontainer {
      background-color:#6666FE !important;
    }
    <?php else: ?>
    #bannercontainer {
    background-image:none !important;
    background-color:#6666FE !important;
    }
    <?php endif; ?>
    </style>
    <?php
    }
    
    add_action("wp_head","my_inline_styles");
    ?>

    Of course, I did it in the Child theme :) Thanks for your support!

    Jose

  8. jcervantes28
    Member
    Posted 1 year ago #

    marking solved.

  9. ahortin
    Member
    Theme Author

    Posted 1 year ago #

    For reference, if you simply need to make some style changes, and you've built a child theme, then add them straight into the style.css file. That's what it's there for. You shouldn't be using a function within functions.php to add them to the site <head>.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic