Looking on the wordpress forums i was unable to find a solution to my sticky problem.
What i want to achieve is to display the sticky post from a specific category, without other posts. There are many standard solutions to this, however my wordpress system is so customised that i cannot use these functions any longer.
Attempting the following conditions is not possible due to the way wordpress handles it’s functions, however i did find a solution with css.
- End the loop with is_sticky
- is_sticky endif;
- is_stuck endwhile;
- is_sticky exit;
See below an excerpt of code from the index.php located in the theme directory:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post();?>
<?php if((!is_sticky()) && ($sticky == 1)) $hide = (“display: none;”);
else $hide = “”; ?>
<?php if(is_sticky() ) $sticky = 1;?>
<!–post title as a link–>
<div align=”center” style=”padding-right: 15px; <?php echo $hide ?>“>
<h2 align=”center” id=”post-<?php the_ID(); ?>”>
<?php the_title(); ?>