判断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
}