Wordpress query_posts为非管理员用户生成奇怪的SQL查询

时间:2013-03-05 08:02:07

标签: wordpress-plugin wordpress

我使用query_posts来获取特定作者的第2页,我的查询是

query_posts(array(
        'author' => $author_id,
        'paged' => $paged,
        'posts_per_page' => $posts_per_page,
        'post_status' => 'publish',
    ));

对于admin,它可以正常生成以下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"

[ “职位”] =>

0 个答案:

没有答案