0

I want to display my selected post as top post which will appear in the top of my post list. I use sticky post for this, but there is a problem in the sticky post option. It shows selected post at the top, but I want to show the top post with a custom title.

  • Welcome to WordPress Stack Exchange! We love to help. Please have a look at the help center and learn how to ask a good question. We need narrowly-scoped and precise questions to provide canonical answers. We always want to know what you've tried yourself so far and where exactly you are stuck in that process. Thank you – leymannx Apr 29 at 6:59
2

Let's say you wanna prepend the word "Special: " to every stick post's title you can place the following in your functions.php:

add_filter( 'the_title', 'sticky_title' );
function sticky_title( $title ) {

    // Check if a post is set to sticky.
    if ( is_sticky() ) {

        // Prepend "Special: " to post title.
        return 'Special: ' . $title;
    }

    return $title;
}

I want's to design this 'special : ' word into different color and i wants this will appear my every sticky post's left corner... How can i do this?

You could do that with just CSS using post_class() or by hooking into post_class(). Normally the <article> tag already comes with a .sticky class.

If you use a custom theme you can simply have a look at the Twenty Nineteen theme's template-parts/content/content.php and use that approach yourself in your home.php or in whatever template you need it:

if ( is_sticky() && is_home() && ! is_paged() ) {
    printf( '<span class="sticky-post">%s</span>', _x( 'Featured', 'post', 'twentynineteen' ) );
}

enter image description here

  • I want's to design this 'special : ' word into different color and i wants this will appear my every sticky post's left corner... How can i do this? – user166923 Apr 29 at 3:23
  • @user166923 – Answer updated. – leymannx Apr 29 at 6:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.