Closed. This question needs details or clarity. It is not currently accepting answers.admin管理员组文章数量:1023738
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this questionI 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 questionI 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
1 Answer
Reset to default 2Let'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:
Closed. This question needs details or clarity. It is not currently accepting answers.if ( is_sticky() && is_home() && ! is_paged() ) { printf( '<span class="sticky-post">%s</span>', _x( 'Featured', 'post', 'twentynineteen' ) ); }
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this questionI 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 questionI 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
1 Answer
Reset to default 2Let'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
版权声明:本文标题:How can I override the post title when a post is set to sticky? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745542786a2155259.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论