If you are using setup_postdata( $post )
you need to use the global $post
as for some reason it does not work without that specific variable. Once you manually set $post
to a new value, you are altering the $post
global, so you will need to reset it back to the current post of the main query.
Apart from that, you should never use any global variables set by WordPress as a custom variable as this can cause non debuggable issues and unexpected results from your code. Breaking a global variable and then trying to debug such an issue will drive you up a mountain 😉
In your specific use case, you need to add wp_reset_postdata()
immediately after your custom query is done
$post = get_post(17);
$page_template = get_post_meta(17);
setup_postdata( $post );
include($page_template['_wp_page_template'][0]);
wp_reset_postdata();