Calling body_class and wp_nav_menu for a different post

This approach sounds complex, hacky and not reliable, as there could be various filters/actions that might be skipped.

Two alternative semi-workarounds comes to mind, to get the wp_nav_menu() and body_class(), for a given post page:

  1. Use the HTTP API / Ajax to make a request for the post page and e.g. use a GET parameter to return only these values. This might be slow for many posts.

  2. Generate these values when the post page is loaded and cache it for some time. We could e.g. store it with the post meta API or use the transients API, depending on our needs. We would have to keep in mind that the amount of traffic can vary for each post page.