Here is the code (with yours included) inside a function I'm building for a Thesis Skin.
Here is the process:
1. I want this sub-loop to check for stickies (and it does)
2. If there is a sticky, print it
3. If not, do nothing
<?php
function tt_emergency_post_html() {
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$sticky = get_option('sticky_possdts');
if ( ! empty($sticky)) {
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>
<?php
} }
With the code above it doesn't do either...
I was trying (and failing miserably):
<?php
function tt_emergency_post_html() {
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 1);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );?>
<?php if($sticky >'0') { ?>
<div id="emergency">
<?php if (have_posts()) : 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>
<?php else: ?>
NO STICKY!
<?php }?>
<?php }