Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134430

Jack on "Display future single post from specific category"

$
0
0

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 all articles
Browse latest Browse all 134430

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>