admin管理员组

文章数量:1326061

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.

本文标签: phpQuery by pagename not Working