Hi there,
You seem to be trying to hitch a few elements on the nav bar’s sticky functionality.
If that’s the case, I don’t think you need the PHP snippet you’re adding in and the secondary nav bar.
You can just enable the “Use navigation as header” and create a Block or Hook element to create a secondary nav bar hooked to generate_inside_navigation so it rides in on the sticky script.
We just need a few custom CSS afterwards to fit your layout.