• If a caching plugin hooks into pre_wp_nav_menu and returns HTML, WordPress will return it immediately and skip most of the wp_nav_menu() function.

    Therefore, your plugin never has the opportunity to switch back to the origin site and you’re left with a broken site after rendering the menu.

    You need to hook pre_wp_nav_menu very late, and then check if there is HTML to return. Only switch sites if it’s safe to proceed.

  • The topic ‘Check for existing HTML in ‘pre_wp_nav_menu’ before switching sites!’ is closed to new replies.