• Hi

    I am trying to use is_home() to highlight page menu dynamically.

    My front page is a static page, and my posts page is, say, PageX.

    The WordPress Codex says:
    “If you select a static Page as your frontpage (see below), this tag will be applied to your “posts page”.”

    So I would expect is_home(PageX->ID) to be true, and false for any other page.

    I have the following codes in my header.php (at this point $links is an array containing a list of my pages). In my CSS, page-active applies an orange color to the text.

    My problem is that, when PageX is shown, all the links are displayed in orange.

    Can anyone help me see what I’m doing wrong? Thank you very much!

    foreach($links as $i => $page)
    {
    $links[$i] = '<li class="page-' . ((is_page($page->ID) || is_home($page->ID)) ? 'active' : 'item') . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a></li>'
    }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help with is_home() please’ is closed to new replies.