Support » Fixing WordPress » is_home() and is_front_page() not working

  • Resolved richdal

    (@richdal)


    I was trying to setup a condition on the homepage so the sidebars would not display. I tried checking is_home() and is_front_page() but neither of those are showing a match.

    I have a static page configured under Pages as “Home – Front Page” and that page loads as the home page, but can’t tell what I’m missing to get either of those two checks to work? That page has a couple shortcodes to display the login and registration forms and they are both working correctly.

    WordPress 4.4.2
    BuddyPress 2.4.3
    Theme: Genbu

    Settings => Reading
    Front page displays: A static page
    Posts page: none selected (don’t need)

    Pages: Have a “Home — Front Page” configured

    In my theme’s functions.php file I tested for both but the borders were coming out red instead of blue

    if(is_home() || is_front_page()) {
    print '<style type="text/css">';
    print <<<HTML
    div#sidebar-primary-wrap { border:1px solid #0000ff; }
    div#sidebar-secondary-wrap { border:1px solid #0000ff; }
    HTML;
    print '</style>';
    } else {
    print '<style type="text/css">';
    print <<<HTML
    div#sidebar-primary-wrap { border:1px solid #ff0000; }
    div#sidebar-secondary-wrap { border:1px solid #ff0000; }
    HTML;
    print '</style>';
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.