Display Future Sticky Posts
-
I have been rattling my brain around this. The idea is that I will eventually will have two conditional loops (based on whether someone is an admin or not). As of now if they are not an admin, it loads this:
global $post; $which_category = get_the_category($post->ID); $sticky = get_option( 'sticky_posts' ); /* Sort the stickies with the newest ones at the top */ rsort( $sticky ); /* Get the 2 newest stickies (change 2 for a different number) */ $sticky = array_slice( $sticky, 0, 1 ); /* Query sticky posts */ $category_cover = new WP_Query(array( 'post__in' => $sticky , 'caller_get_posts' => 1, 'post_status' => 'publish' )); while ( $category_cover->have_posts() ) : $category_cover->the_post(); $cover_img_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' ); ?> <div class="cover_wrapper" style="background:url('<?php echo $cover_img_url[0]; ?>') no-repeat;"> <?php if( is_home()) { ?> <a style="width:940px; height:520px;" class="block abs" href="<?php the_permalink();?>"></a> <ul class="cover_links abs br grid_7"> <li><h2><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2> <p><?php the_excerpt();?></p> </li> <?php if( get_field ('photographer_name') ) { echo '<li class="frgt">'; echo '<dt>Photographer</dt>'; echo '<dd>' . get_field('photographer_name') . '</dd></li>'; } ?> <?php if( get_field ('creative_director_name') ) { echo '<li class="frgt">'; echo '<dt>Creative Director</dt>'; echo '<dd>' . get_field('creative_director_name') . '</dd></li>'; } // is_home(end) ?>
Now what I would want is to add a conditional loop that also includes a ‘post_status’ variable to the WP Query. That way I can be logged in and see what the upcoming stories are going to look like.
When I try to simply add this to the top:
$category_cover = new WP_Query(array( 'post__in' => $sticky , 'caller_get_posts' => 1, 'post_status' => 'future' ));
This yields the one sticky post that is published to disappear. Is there a link someone can throw me?
- The topic ‘Display Future Sticky Posts’ is closed to new replies.