Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End is_front_page returning false

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #196868
    amidigital
    Participant

    I would like the front page to echo class=”none”

    Sadly, it is echoing class=”GATSBG1″

    <?php if ( is_page (array('75-chrome-shop', '75-chrome-shop-galleries', '75-chrome-shop-winners')) || in_category('75-chrome-shop')) {
    echo 'class="chromeBG" ';
    } elseif ( is_page (array('fitzgerald-truck-show', 'fitzgerald-winners', 'fitzgerald-galleries')) || in_category('fitzgerald')) {
    echo 'class="fitzgeraldBG"';
    } elseif ( is_page (array('the-great-american-trucking-show', 'gats-galleries', 'gats-winners' )) || in_category('gats')) {
    echo 'class="GATSBG1"';
    } elseif ( is_page('driver-profiles')) {
    echo 'class="GATSBG2" ';
    } elseif ( is_front_page()) {
    echo 'class="none" ';
    } else {
    echo 'class="GATSBG3"';
    }
    ?>

    Thanks!

    #196870
    Senff
    Participant

    Obviously, it’s getting class GATSBG1 because of your home page matches this condition:

    is_page (array('the-great-american-trucking-show', 'gats-galleries', 'gats-winners' )) || in_category('gats'))
    

    And so it will skip checking all the other conditions (including the check if it’s the home page).

    If you want to set it to “none” on the home page no matter what, then you should start your entire check with that condition:

    if ( is_front_page()) {
       echo 'class="none" ';
    } else {
      // all your other stuff here
    }
    
    #196938
    amidigital
    Participant

    Yea it is strange because the home page is none of those pages nor in that category.

    But moving it to the top is a good idea.
    Thanks again.

    #196961
    Alen
    Participant

    is_front_page() will return true if:

    • the main blog page is being displayed
    • and the Settings->Reading->Front Page display is set to “Your latest posts”

    or

    • when Settings->Reading->Front Page is set to “A static page” and the “Front Page” value is the current Page being displayed.

    You can find more information including the description here: http://codex.wordpress.org/Function_Reference/is_front_page

    Hope that helps,
    Alen

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.