判斷wordpress文章是否有摘要,有摘要顯示摘要,沒(méi)的摘要顯示指定內(nèi)容。
if ( ! has_excerpt() ) {
echo 'wodepress.com Display the specified content when no summary is entered';
} else {
the_excerpt();
}
這個(gè)常用到wordpress模板的列表頁(yè)面
也可以用下面的代碼來(lái)實(shí)現(xiàn)
global $post;// wodepress.com First, obtain the global variable $post
if ( emptyempty( $post->post_excerpt ) ) {
// If the article does not have a summary, execute this code
} else {
// If the article has an abstract, execute this code
}