Display future single post from specific category
-
I’m using this code in my functions.php file, but it displays all future posts, no matter the categoru:
// Show Single Future Posts add_filter('the_posts', 'show_future_posts'); function show_future_posts($posts){ global $wp_query, $wpdb; if(is_single() && $wp_query->post_count ==0){ $posts = $wpdb->get_results($wp_query->request); } return $posts; }
so I added && in_category(‘8’) after is_single(), but that doesn’t work.
// Show Single Future Posts add_filter('the_posts', 'show_future_posts'); function show_future_posts($posts){ global $wp_query, $wpdb; if(is_single() && in_category('8') && $wp_query->post_count ==0){ $posts = $wpdb->get_results($wp_query->request); } return $posts; }
Can someone please tell me how to fix this?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Display future single post from specific category’ is closed to new replies.