最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Query by pagename not Working

programmeradmin0浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论