WordPress的摘要顯示方式

2022-08-19 12:24:10 字數 751 閱讀 9055

wordpress的後台有摘要顯示的欄目,如果沒有顯示,需要設定一下,如圖

在列表頁現實的內容的時候,一般是有摘要的顯示摘要,沒有摘要的擷取文章的前一部分文字。**如下

<?php if

(has_excerpt()) the_excerpt();

else

echo mb_strimwidth(strip_tags($post->post_content),0,400,'......[閱讀全文]');?>

**中的「400」指的是顯示字元,兩個字元等於乙個漢字。

有的時候,摘要的太長了,顯示出來不好看,那可以在functions.php檔案新增這段**,控制摘要的顯示字數

*控制摘要字數*/

function new_excerpt_length($length

) add_filter("excerpt_length", "new_excerpt_length");

摘要預設的結尾方式是以[...]這樣的,這不太符合國人的閱讀習慣,可以自定義摘要的結尾方式,在functions.php中插入這段**

function new_excerpt_more($more

) add_filter("excerpt_more", "new_excerpt_more");

完美解決WordPress摘要顯示問題

前些日子用wp搭建了乙個blog,感覺其最大的問題有兩個,一是在首頁使用摘要的方式顯示文章,一為官方提供的備份 恢復功能實在太弱,根本達不到大多數人的要求。其中第乙個問題曾多次被討論過,大家提供的方案有兩個 見的二樓 採用手動截斷文章的方法,這個不是真正意義上的摘要,使用 more 標籤,即在寫文章...

wordpress設定主頁顯示摘要及字數

說明 本人使用的wordpress主題是twentysixteen,其它主題應該類似。首先,開啟functions.php檔案,把下面的 放到末尾。display the content in short words function dm strimwidth str start width tr...

WordPress 摘要字數控制

共有兩種方法 1.修改對應主題的index.php 或者home.php 檔案中的 the content read more.inove the content為獲取文章全部內容的api。function wp trim excerpt text add filter the excerpt mu...