我使用了原始答案,并对其进行了修改,以处理不同的帖子类型:
// Customise the Excerpt field title and description via WP translation.
// Change the $post_types array to change the default Excerpt metabox title and description. The description is generic but substitutes the post_type to make it specific to the current post type.
add_filter( \'gettext\', \'change_excerpt_info\', 10, 2 );
function change_excerpt_info ( $translation, $original ) {
$post_types = array( "service", "workshop", \'team\' );
$post = get_post( $post );
$posttype = \'\';
if ( $post ) {
$posttype = $post->post_type;
}
if ( in_array($posttype, $post_types) ) {
if ( \'Excerpt\' == $original ) {
return ucfirst($posttype) . \' Teaser\'; // Will appear as Service Teaser, Team Teaser, etc.
} else $pos = strpos($original, \'Excerpts are optional hand-crafted summaries\');
if ($pos !== false) {
// The Summary will incorporate the post_type into the description.
$summary = \'This field will be displayed as a teaser or summary of anywhere this \' . $posttype . \' appears in a grid layout. You should always write a teaser of about 30 words. It will never be displayed on the actual \' . $posttype . \' page, so you can repeat content from other fields on this editing screen if you want.\';
return $summary;
}
}
return $translation;
}