WEB WordPress static front page question

Discussion in 'OT Technology' started by White Stormy, Jun 28, 2009.

  1. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    I'm running the latest WP.

    I'm using a page titled 'Home' as the static front page.
    I'm using a page titled 'Press' as the posts page.

    I use is_front_page() in the theme to add style to the home page link in the navbar.

    But is_front_page() returns true on the posts page as well! So the home page link in the navbar is being highlighted as active on both the home page and the posts page.

    I tried using is_page('home') instead of is_front_page(), but even that returned true on the posts page (which has the title 'Press'). is_front_page() only returns true on the home page and the posts page.. no other pages are affected. This is driving me crazy.

    Any ideas? TIA
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,923
    Likes Received:
    11
    Location:
    Los Angeles
    try
    Code:
    if (is_front()) {
      //...
    }
    
     
  3. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    is_front() must be obsolete.. using it breaks the site, and there's no page for it on the WP site anymore

    :hs:
     
  4. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,923
    Likes Received:
    11
    Location:
    Los Angeles
    You can always try this... Not recommended, but it would work, I think.

    Code:
    if ($paged <= 1) {
      // front page items etc...
    }
    
    This should return true on the first page of the archive.
     
  5. fishbulb

    fishbulb Active Member

    Joined:
    Oct 29, 2001
    Messages:
    6,848
    Likes Received:
    4
    Location:
    md
    Strange that is_front_page doesn't work in that case, I'm using it in the header file in a similar scenario on one of my sites.

    This'll work to test for the post id outside of the loop:

    Code:
    global $post;
    $thePostID = $post->ID;
    
    if($thePostID == $the-PostID-of-the-static-front-page){
    
     // do whatever you want to do
    
    }
    
    
     
  6. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    well now I feel like an idiot.

    it was a custom variable in the theme that was being set by a conditional using is_home() instead of is_front_page(). it was ONLY used on the home page link in the navbar

    I changed the condition to is_front_page() and was able to remove the additional code I had put in (that I mentioned in first post, but was not at all causing my problem) when I found out the other day that it hadn't been working with a static home page.

    sheesh.
     

Share This Page