为WordPress内容页面添加摘要功能

某些页面可能没有内容摘要功能,可以自行添加,只需两步即可拥有摘要功能:

  • 将以下代码添加到正在使用主题的 functions.php 文件内:
add_action('init', 'page_excerpt');
function page_excerpt() {
add_post_type_support('page', array('excerpt'));
}
  • 在需要调用的地方放入以下代码:
if( has_excerpt() ){
the_excerpt();
}
《为WordPress内容页面添加摘要功能》版权归逐凨所有
转载请保留原文链接:https://izhizu.com/wordpress/112.html
THE END
分享
二维码
< <上一篇
下一篇>>