Title: Sticky Post Function Not Working. Please Help?
Last modified: August 21, 2016

---

# Sticky Post Function Not Working. Please Help?

 *  Resolved [David Venter](https://wordpress.org/support/users/davidventernet/)
 * (@davidventernet)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/sticky-post-function-not-working-please-help/)
 * Hi guys. I’m having an issue with sticky posts not working correctly in a custom
   theme which I’m developing (I’m still kinda new to building themes from scratch).
 * I would like all sticky posts to show up first on the home page, followed by 
   normal posts. Here is my index.php code:
 *     ```
       <?php get_header(); ?>
       	<?php if ( have_posts() ) : ?>
       	<?php while ( have_posts() ) : the_post(); ?>
       	<?php get_sidebar(); ?>
       		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       			<div class="time-and-date">
       				<div class="post-date">
       					<div class="post-date"><span class="date-icon"></span><?php the_time( 'l, F j, Y' ); ?></div>
       				</div>
       				<div class="post-time">
       					<div class="post-time"><?php the_time( 'h:i A, T' ); ?><span class="time-icon"></span></div>
       				</div>
       			</div>
       			<a href="<?php the_permalink(); ?>"><?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?></a>
       			<div class="post-title">
       			<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
       			<div class="post-content">
       				<?php the_content(); ?>
       				<?php wp_link_pages(); ?>
               	</div>
               	<div class="post-sharing"></div>
               	<div class="post-meta"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Permalink</a> | Comments | <a href="http://www.addthis.com/bookmark.php" target="_blank">Share</a></div>
       			<div class="post-categories"><span class="post-tags"><?php the_tags( 'Tags: ', ' ', ''); ?></span></div>
       		</div>
       		<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
       		<?php else : ?>
       		<?php endif; ?>
       	</div>
       <?php get_footer(); ?>
       ```
   
 * If you go to [http://dev.davidventer.net/wordpress](http://dev.davidventer.net/wordpress)
   and scroll down, you will see a post titled ‘Layout Test’. This is a sticky post
   which is supposed to show up before all other posts on the home page, but it 
   does not.
 * I’ve googled around a bit and found some blogs saying that I need to have a sticky
   class in my CSS in order for the stickies to show up first. I have the following
   in my CSS:
 *     ```
       .sticky {
       background: #ffffff;
       }
       ```
   
 * I’m probably just missing something basic here which I’ve overlooked. Maybe there
   is something I need to put in my functions.php? or some other small php call 
   which I’m missing from my loop? I don’t know. It’s driving me nutty. Please help!

The topic ‘Sticky Post Function Not Working. Please Help?’ is closed to new replies.

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [stickies](https://wordpress.org/support/topic-tag/stickies/)
 * [Sticky posts](https://wordpress.org/support/topic-tag/sticky-posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [David Venter](https://wordpress.org/support/users/davidventernet/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/sticky-post-function-not-working-please-help/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
