在SE中编写问题时,我已经找到了解决方案:
add_filter( \'get_the_excerpt\', \'get_custom_the_excerpt\' );
function get_custom_the_excerpt($excerpt) {
$post = get_post();
$format = get_post_format( $post );
// modify excerpt if it is a quote, for example set title as author
if ($format == \'quote\') {
$output = \'<q>\'. $excerpt. \'</q>
<p class="quoted">\'.get_the_title().\'</p>\';
}
// return excerpt without change
else {
$output = $excerpt;
}
return $output;
}
查看详细信息
get_the_excerpt() 和
get_post_format().