WordPress.org

Ready to get started?Download WordPress

Forums

is_home works....is_front_page doesn't (3 posts)

  1. TabithaF
    Member
    Posted 1 year ago #

    I'm sure I'm missing something obvious here, I just need to call a custom header.php file for a static home page. I'm able to call it for the blog page (News) and it works, when I switch to "is_front_page" nothing happens.

    I've tried the reset query solution to no effect. Here's the code I'm using:

    if (is_front_page()) :
      get_header('home');
    else :
      get_header();
    endif;

    I've never had problems with this before, so I'm wondering what I'm missing. I've even tried calling the specific page, is_page('32') with no luck. The only page I can get my custom header on is the blog page.

    Thanks for any help!

  2. toocoolone
    Member
    Posted 1 year ago #

    Check your setting in the admin menu: Settings->Reading->Front page displays. Are you displaying a static page or your latest posts? Depending on this setting decides how these two functions act.

    is_home() is a function that returns true when the "blog posts index page" is loaded. It works on blog pages only. (Codex)

    is_front_page() is a function that returns true depending on the setting in your Settings->Reading->Front page displays. If you are set to "Your latest posts" it returns true just like is_home() when you are on the page showing your latest posts. If the option is set to "A static page" and your static home page is showing, the function will return true only on that page. (Codex)

  3. ronzcani
    Member
    Posted 1 year ago #

    What is selected on your Settings >> Reading ? "Your Latest posts" or "static page (Home, Blog)". If "Your Latest posts" is selected you have to use is_home() instead.

Topic Closed

This topic has been closed to new replies.

About this Topic