Problem filtering query to allow displaying drafts (even for not logged users)
-
Hi, I have a draft post ?p=7149.
I would like to be able to see it even if i’m not logged on the website.function my_get_posts($query) { if (is_admin())return $query; if($query->query_vars['suppress_filters'] )return $query; $query->set('post_status','any'); return $query; } add_filter( 'pre_get_posts', 'my_get_posts' );
When I print the query, I got
SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 7149 AND wp_posts.post_type = 'post' AND (wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft') ORDER BY wp_posts.post_date DESC
which returns me results in phpmyadmin.
But when I access ?p=7149 I got a PAGE NOT FOUND.
Seems is_404 is set to TRUE.
When accessing ?post_type=post; the post #7149 is shown.
So seems it has something to see with the fact that we are viewing a single post.Does anybody have an idea about this ?
Thanks !
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem filtering query to allow displaying drafts (even for not logged users)’ is closed to new replies.