• 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]

    https://pastebin.com/8ZLH2bej

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Zotte Duivel

    (@zotte-duivel)

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

    Thread Starter Zotte Duivel

    (@zotte-duivel)

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Walker – changing class for is_home()’ is closed to new replies.