admin管理员组文章数量:1287942
I've been looking for an answer to this question for a long time, but haven't found anything: how come when I use the_excerpt() on a given site it doesn't automatically print the first few characters of the content?
The excerpt only prints it if something has been added to the WordPress summary field of the post.
How can I fix this problem? With other sites this does not happen and if no text is added on the summary the excerpt is generated automatically.
What could it be that the excerpt is not automatically generated?
My situation is similar to this: Automatic Excerpt Not Working
but your response did not provide me with any advice unfortunately.
I've been looking for an answer to this question for a long time, but haven't found anything: how come when I use the_excerpt() on a given site it doesn't automatically print the first few characters of the content?
The excerpt only prints it if something has been added to the WordPress summary field of the post.
How can I fix this problem? With other sites this does not happen and if no text is added on the summary the excerpt is generated automatically.
What could it be that the excerpt is not automatically generated?
My situation is similar to this: Automatic Excerpt Not Working
but your response did not provide me with any advice unfortunately.
Share Improve this question asked Oct 14, 2021 at 7:20 Matteo FeduziMatteo Feduzi 299 bronze badges1 Answer
Reset to default 1By default, the_excerpt()
, doesn't uses the post/page content wysiwyg, it has its own textarea, that by default is not visible, you need to enable it first via screen options.
After you checked this checkbox you can scroll down to the bottom of the post/page and see a new textarea, this is the excerpt.
If you want to use the content (wysiwyg, the_conetnt()
or get_the_content()
) as excerpt, you will need to use wp_trim_words.
Something like this.
// the second argument is how many words to trim, default is 55
<?= wp_trim_words(get_the_content(), 30); ?>
Anothe option, if you want to keep the html structure would be to do this.
<?= force_balance_tags(html_entity_decode(wp_trim_words(htmlentities(wpautop(get_the_content())), 30))); ?>
本文标签: phpAutomatic excerpt is not shown with theexcerpt() command
版权声明:本文标题:php - Automatic excerpt is not shown with the_excerpt() command 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741271044a2369303.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论