This is my 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:
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
Sorry for bad english.
Here is from the wordpress codex:
post_status (string / array) - use 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. By default protected statuses are 'future', 'draft' and 'pending'.
http://codex.wordpress.org/Class_Reference/WP_Query Go down to status parameters.
If you want add.. 'post_status' => 'publish' to your array to only show the published posts in the query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.