Show future posts for logged-in users
-
i want to show the future posts only when a user is logged in.
The posts should not be display in any category, index page etc.
I link to the post with an own script/link.this is my code
add_filter('the_posts', 'show_future_posts'); function show_future_posts($posts) { global $wp_query, $wpdb; if(is_single() && $wp_query->post_count == 0) { if(is_user_logged_in()) { $posts = $wpdb->get_results($wp_query->request); return $posts; } else { wp_redirect('https://domain.com/wp-login.php?action=register'); exit(); } } }
The problem is that i get an not found (Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post. on the index.php page but i dont know why because in this line
if(is_single() && $wp_query->post_count == 0)
i say that the code only should run on an single page.
Can anybody help me please?
- The topic ‘Show future posts for logged-in users’ is closed to new replies.