WordPress页面增加文章摘要

WordPress页面与文章有个区别,页面没有文章摘要的功能,可以通过add_post_type_support来实现。

将以下代码添加至WordPress主题functions.php

add_action('init', 'page_excerpt');
function page_excerpt() {
    add_post_type_support('page', array('excerpt'));
}

调用方法和文章摘要相同

if( has_excerpt() ){
    the_excerpt();
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注