Custom Walker - changing class for is_home() (3 posts)

  1. Zotte Duivel
    Posted 4 years ago #

    Stuck a custom walker extension in to control list output so I could run a nav menu through a jquery lavaLamp effect. Got it working, but now trying to output class="current" for the
    <li> of the current page only. Tried this:

    if (this.is_home()){ $class_names = ' class="current"';}
    		   else { $class_names = ' class="'. esc_attr( $class_names ) . '"'; }
               $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';

    but its returning true for every item. I'm guessing I have a scope issue, but as I'm not good at programming I'm not sure what the problem is. Can anyone enlighten me? Here's the full function:

    [code moderated - remember to use the pastebin for any code over the forum limit of 10 lines]


  2. Zotte Duivel
    Posted 4 years ago #

    This is implemented in functions.php and is being called from header.php, just to clarify.

  3. Zotte Duivel
    Posted 4 years ago #

    Ok, so after doing some more reading I see the problem is in the initialization... can anyone suggest a way around this? Maybe using add_action - although I seem to be having trouble implementing it. Will really appreciate any assistance!

Topic Closed

This topic has been closed to new replies.

About this Topic