admin管理员组

文章数量:1023738

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 years ago.

Improve this question

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.

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 years ago.

Improve this question

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.

Share Improve this question edited Apr 28, 2019 at 9:19 Fayaz 9,0172 gold badges33 silver badges51 bronze badges asked Apr 28, 2019 at 1:43 user166923user166923 1 1
  • 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 – norman.lol Commented Apr 29, 2019 at 6:59
Add a comment  | 

1 Answer 1

Reset to default 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' ) );
}

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 years ago.

Improve this question

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.

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 years ago.

Improve this question

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.

Share Improve this question edited Apr 28, 2019 at 9:19 Fayaz 9,0172 gold badges33 silver badges51 bronze badges asked Apr 28, 2019 at 1:43 user166923user166923 1 1
  • 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 – norman.lol Commented Apr 29, 2019 at 6:59
Add a comment  | 

1 Answer 1

Reset to default 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' ) );
}

本文标签: How can I override the post title when a post is set to sticky