Hi Dinesh, I’m not sure about Andrew’s issue, but I think it’s because the code is only looking at the main wp query and not a custom one, hence it might break, am I right (I’m still learning 🙂 )?
This issue I had with my menu breaking on category pages was solved below by Jeremy and Steve’s comments.