Sticky Post Conditional PHP
-
I’m creating an “emergency/breaking news” section above the fold AND outside The Loop.
When there is a sticky post, I want to display it (just one) and if there isn’t, do nothing. See image example: Sticky! and No Sticky
The code below displays a Sticky post just fine, I just need to add the conditional tags, therefore I’m lost.
Thanks
<?php $sticky = get_option('sticky_posts'); rsort( $sticky ); $sticky = array_slice( $sticky, 0, 1); query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) ); ?> <div id="emergency"> <?php if (have_posts()) ?> <?php while (have_posts()) : the_post(); ?> <?php images('1', '400', '', 'alignleft', true); ?> <h1>BREAKING NEWS</h1> <h2><?php the_title(); ?></h2> <p><?php excerpt('50'); ?>...<br /><a href="<?php the_permalink(); ?>"><?php echo thesis_teaser_link_text(); ?></a></p> <?php endwhile; ?> </div>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Sticky Post Conditional PHP’ is closed to new replies.