Support » Fixing WordPress » Sticky post styling on pages other than the homepage

  • Resolved COTKPR


    I am looking to style sticky posts, which I have successfully been able to do via:

    <?php post_class(); ?>

    However, the class [and thus the style(s)] only appends to the post(s) on the homepage – not to any of the paged pages or the category/tag/search pages. Is there a way to have the .sticky class append to all posts which have been “stickied” site wide?

    Any help/thoughts would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    web search returned a link to
    however, this cannot be combined with post_class() as it simply echos ‘ sticky’.

    possibly, using the conditional tag is_sticky() you could try:

    <?php post_class((is_sticky()?'sticky':'')); ?>


    Thanks for your quick reply –

    I actually want it to echo “sticky” – just not only on posts that are on the homepage. Currently echoing “.sticky” in the HTML is only happening on the homepage posts…

    (PS: The above code you supplied does not work)



    Forum Moderator

    please post a link to your site;
    and paste the full code of your single post template (single.php) into a and post the link to it here – see

    want it to echo “sticky”

    then try to use this code



    alchymyth –
    Perfect! I had never used <?php sticky_class();?> before. (Didn’t know it existed)

    I wound up doing this (utilizing conditionals) at the start of the div:

    <?php if ( is_sticky() ) {?>
    <div id="post-<?php the_ID(); ?>" class="partial flowfix clearfix<?php sticky_class(); ?>">
    <?php } else { ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class('partial flowfix clearfix'); ?>>
    <?php } ?>

    Works like a charm. Thanks again for your help, I’ll mark this as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sticky post styling on pages other than the homepage’ is closed to new replies.