WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page div background (5 posts)

  1. SpeedyLeon
    Member
    Posted 1 year ago #

    Hi guys,

    Before we start, I am using a child theme, but I cannot post the link to the website, but I do not believe that this question requires any 'visual aids'.

    Essentially, WordPress twentyeleven has a div id="page" class="hfeed", I was wondering, is there a way to make it so that, on the home page, the CSS is set to have no background, and on every other page, the CSS is set to have a background? If it is possible, how would I go about achieving such a thing?

  2. Tom Combs
    Member
    Posted 1 year ago #

    create a template page for the homepage and change the div id to something else, ex- <div id="pagehome">

    then set the css:
    #pagehome {background:none;}

    That might be the easiest way.

  3. SpeedyLeon
    Member
    Posted 1 year ago #

    I dont think thats quite what I mean.

    In header.php you have the following:

    <body <?php body_class(); ?>>
    <div id="page" class="hfeed">
    header id="branding" role="banner">

    ETC.

    I was hoping to be able to call that div conditionally. So that if its the homepage, it will call div id="page" with a different class (say, class="home") and if it wasnt the home page, it would call it with class="hfeed".

    Is such a thing doable?

  4. SpeedyLeon
    Member
    Posted 1 year ago #

    Wop, lets backtrack! :P

    Thanks Tom, your post gave me a good idea of an alternative way to solve my problem using your advice, I really appreciate the help =]

    Have a good one.

  5. Tom Combs
    Member
    Posted 1 year ago #

    I'm not 100% sure, but I don't think you can apply separate set of attributes the same id or class.

    I think you'll have to create a second page id, but rather than creating a template page, you could use and if/else statement.

    Try something like this:
    #pagenobackground {background:none;}

    then in your header use this:

    <?php
    // HOME
    if ( is_page('home') ) {?>
    <div id="pagenobackground" class="hfeed">

    <?php }
    else { // all other pages ?>
    <div id="page" class="hfeed">
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic