判斷wordpress文章是否有摘要,有摘要顯示摘要,沒的摘要顯示指定內容。
if ( ! has_excerpt() ) {
echo 'wodepress.com Display the specified content when no summary is entered';
} else {
the_excerpt();
}
這個常用到wordpress模板的列表頁面
也可以用下面的代碼來實現
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
}