我希望我的摘录短于默认的55个字符。所以我在Wordpress中找到了这个代码documentation:
/**
* Filter the except length to 20 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return 20;
}
add_filter( \'excerpt_length\', \'wpdocs_custom_excerpt_length\', 999 );
如何将此筛选器应用于代码,如下所示:
<?php the_excerpt(); ?>