Support » Plugins and Hacks » Hacks » Style latest post as sticky

  • Hi,

    I want to style the latest post in the same way that my theme styles sticky posts on my homepage.

    Essentially what I am trying to do is style the latest blog post in a particular way.

    And when I say latest post, I mean the latest of all categories, bar one particular one.



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


    Forum Moderator

    guessing that the styling is triggered by the post_class() .sticky, try to use a filter;

    add this to functions.php of your theme:

    function add_sticky_class_to_latest_post($classes) {
    if($wp_query->current_post==0 && !is_paged() && is_home() && get_post_type() == 'post' ) $classes[] = 'sticky';
    return $classes;

    Thanks! How do I exclude a particular category from being included?

    And, how do I also include images in the ‘sticky’ formatting? I’m using the origin theme as below

    <?php do_atomic( 'before_entry' ); // origin_before_entry ?>
    						<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    							<?php do_atomic( 'open_entry' ); // origin_open_entry ?>
    							<?php if ( current_theme_supports( 'get-the-image' ) ) {
    								if ( is_sticky ( $post->ID ) ) {
    								get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'image_class' => 'featured' ) );
    								} else {
    								get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'thumbnail', 'image_class' => 'featured' ) );
    							} ?>

    You’ll see that it checks if a post is sticky and then calls the image correctly. How can I apply this image settings when the post is sticky to the latest post?

    Thanks – much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Style latest post as sticky’ is closed to new replies.