Title: su_posts &#8211; Sticky posts custom CSS
Last modified: October 19, 2020

---

# su_posts – Sticky posts custom CSS

 *  Resolved [serpher](https://wordpress.org/support/users/serpher/)
 * (@serpher)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/su_posts-sticky-posts-custom-css/)
 * Is there a way to apply custom CSS to sticky posts via su_posts??

Viewing 1 replies (of 1 total)

 *  Thread Starter [serpher](https://wordpress.org/support/users/serpher/)
 * (@serpher)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/su_posts-sticky-posts-custom-css/#post-13552124)
 * The solution I came up with is to add `<div <?php post_class() ?> >` in default-
   loop.php and
 *     ```
       <div class="su-posts su-posts-default-loop">
   
       	<?php if ( $posts->have_posts() ) : ?>
   
       		<?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
   
       			<div id="su-post-<?php the_ID(); ?>" class="su-post">  
       				<div <?php post_class() ?> >
   
       				<?php if ( has_post_thumbnail( get_the_ID() ) ) : ?>
       					<a class="su-post-thumbnail" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
       				<?php endif; ?>
   
       				<h2 class="su-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
   
       				<div class="su-post-meta">
       					<?php _e( 'Posted', 'shortcodes-ultimate' ); ?>: <?php the_time( get_option( 'date_format' ) ); ?>
       				</div>
   
       				<div class="su-post-excerpt">
       					<?php the_excerpt(); ?>
       				</div>
   
       				<?php if ( have_comments() || comments_open() ) : ?>
       					<a href="<?php comments_link(); ?>" class="su-post-comments-link"><?php comments_number( __( '0 comments', 'shortcodes-ultimate' ), __( '1 comment', 'shortcodes-ultimate' ), '% comments' ); ?></a>
       				<?php endif; ?>
       				</div>
   
       			</div>
   
       		<?php endwhile; ?>
   
       	<?php else : ?>
       		<h4><?php _e( 'Posts not found', 'shortcodes-ultimate' ); ?></h4>
       	<?php endif; ?>
   
       </div>
       ```
   
 * and in functions.php
 *     ```
       function my_sticky( $classes ) {
           global $post;
           if ( is_sticky( $post->ID ) ) {
                   $classes[] = 'sticky';
           }
   
           return $classes;
       }
       add_filter( 'post_class', 'my_sticky' );
       ```
   
 * Don’t know if it’s correct but it works.
    -  This reply was modified 5 years, 7 months ago by [serpher](https://wordpress.org/support/users/serpher/).

Viewing 1 replies (of 1 total)

The topic ‘su_posts – Sticky posts custom CSS’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [su_posts](https://wordpress.org/support/topic-tag/su_posts/)

 * 1 reply
 * 1 participant
 * Last reply from: [serpher](https://wordpress.org/support/users/serpher/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/su_posts-sticky-posts-custom-css/#post-13552124)
 * Status: resolved