我正在使用 query_posts 获取特定作者的第 2 页,我的查询是
query_posts(array(
'author' => $author_id,
'paged' => $paged,
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
));
对于管理员来说,它可以正常生成以下 SQL 查询:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (wp_posts.post_author = 13) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 10, 10"
但是对于任何其他未登录或未登录的用户,不会执行 SQL 查询并返回 null 生成以下查询:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.post_author = 13) AND wp_posts.post_type = 'post' AND (( ( ( ( ( 1=2 ) ) ) ) AND wp_posts.post_status = 'publish' )) ORDER BY wp_posts.post_date DESC LIMIT 20, 10"
[“帖子”]=>