简体   繁体   English

WP_Query diff请求登录后

[英]WP_Query diff request when logged in

This is my wp_query: 这是我的wp_query:

$postagens = new WP_Query(array(
    'post_type'      => array('social', 'noticia', 'entretenimento', 'esporte', 'video', 'reporter', 'culinaria', 'cobertura', 'entrevista'),
    'posts_per_page' => -1,
    'orderby'        => 'date',
    'order'          => 'desc'
));

When im logged in, this is the $postagens->request: 当我登录时,这是$ postagens-> request:

SELECT al_posts.* FROM al_posts WHERE 1=1 AND al_posts.post_type IN ('social', 'noticia', 'entretenimento', 'esporte', 'video', 'reporter', 'culinaria', 'cobertura', 'entrevista') AND (al_posts.post_status = 'publish' OR al_posts.post_author = 1 AND al_posts.post_status = 'private') ORDER BY al_posts.post_date desc;

if im not logged in: 如果我没有登录:

SELECT al_posts.* FROM al_posts WHERE 1=1 AND ( ( al_posts.post_type = 'social' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) OR ( al_posts.post_type = 'noticia' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) OR ( al_posts.post_type = 'entretenimento' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) OR ( al_posts.post_type = 'esporte' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) OR ( al_posts.post_type = 'video' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) OR ( al_posts.post_type = 'reporter' AND ( 1=1 AND ( ( al_posts.post_status IN ('publish') ) ) ) ) ) AND al_posts.post_type IN ('social', 'noticia', 'entretenimento', 'esporte', 'video', 'reporter', 'culinaria', 'cobertura', 'entrevista') AND (al_posts.post_status IN ('publish','private')) ORDER BY al_posts.post_date desc;

Is it, im waiting for ur response :D 是吗,即时通讯正在等待您的回复:D

Sorry for bad english. 对不起,英语不好。

Here is from the wordpress codex: 这是来自wordpress Codex:

post_status (string / array) - use post status. post_status(字符串/数组)-使用发布状态。 Retrieves posts by Post Status. 通过帖子状态检索帖子。 Default value is 'publish', but if the user is logged in, 'private' is added . 默认值为“发布”, 但如果用户已登录,则添加“专用” And if the query is run in an admin context (administration area or AJAX call), protected statuses are added too. 而且,如果查询是在管理上下文(管理区域或AJAX调用)中运行的,那么也会添加受保护的状态。 By default protected statuses are 'future', 'draft' and 'pending'. 默认情况下,受保护状态为“将来”,“草稿”和“待处理”。

http://codex.wordpress.org/Class_Reference/WP_Query Go down to status parameters. http://codex.wordpress.org/Class_Reference/WP_Query转到状态参数。

If you want add.. 'post_status' => 'publish' to your array to only show the published posts in the query 如果要添加..'post_status'=>'publish'到数组中以仅显示查询中已发布的帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM