如果您希望登录用户和未登录用户都看到相同的内容,那么您只希望看到“已发布”的帖子状态,至少对我来说,向未登录用户显示“私有”帖子没有意义。更改查询以包含该条件。
$most_recent_sticky_post = new WP_Query(
array(
\'post_status\' => array( \'publish\' ),
// Only sticky posts
\'post__in\' => $sticky,
// Treat them as sticky posts
\'ignore_sticky_posts\' => 1,
// Order by date to get the most recently published sticky post
\'orderby\' => date,
// Get only the one most recent
\'posts_per_page\' => 1
)
);
ignore_sticky_posts
, 什么时候
true
正如您所拥有的,将粘性帖子视为普通帖子,这不是您的代码注释所说的,但我认为这就是您的意思。