I try and fail. What could be the problem with the following code:
$pagename = get_post($post_id)->post_name;
global $wp_query;
$wp_query = new WP_Query(array( 'pagename' => $pagename ));
$result = have_posts() // false
The post exists and the variable "$ pagename" is placed approximately. But the query does not receive a post.