Mark a page of a queried menu as active

The code above is correct and includes the answer.
I’ve added a function with a genesis hook to enwrap it so it should just work with copy-past.