[WordPress] 如何顯示 文章摘要 : More Tag 與 the_excerpt()

[WordPress] 如何顯示 文章摘要 : More Tag  與  the_excerpt()

在顯示 文章列表 的頁面中,我們通常需要讓 使用者 可已在更快 在 文章列表 找到想看的文章,我們會只顯示文章的 摘要 來避免頁面內容過於雜亂,而在 WordPress 中這提供了兩種方式,來進行 摘要 的顯示


More Tag :

More Tag 使用上十分容易,只需要在文章內容中,加上 <!--more--!> 的 註解 就可以了,如下:


文章摘要..... <!--more--!> 文章主要內容.....

也可以直接從 WordPress 的 編輯器中 直接 插入:

官方文件 : More Tag

在 版型 開發中,直接用 the_content() 就可以得到效果了


the_excerpt():

在 版型 開發中,直接是用 the_excerpt() 來顯示 文章的摘要

//--post loop
   <?php the_excerpt()?>
//--end loop

這方式建議配合 文章的摘要 來使用,比較能掌握 摘要 顯示出來的內容

官方文件 : the_excerpt()


補充:

如果 使用者 習慣使用 markdown 對文章進行編輯,我建議使用 More Tag 的方式來顯示文章在摘要

the_excerpt() 實用過後,發現對 markdown 的顯示效果不是很好

Facebook 功能: