I want to change the default “Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts.” help text below the Excerpt input area to something more meaningful for my Custom Post Type.

I’ve done something similar with Post Title, using a “translation” filter, but how would I do this with the post excerpt?

Here is my current code:

add_filter('gettext', 'custom_rewrites', 10, 4);
function custom_rewrites($translation, $text, $domain) {

    global $post;

    $translations = &get_translations_for_domain($domain);
    $translation_array = array();

    switch ($post->post_type) {
        case 'model':
            $translation_array = array(
                'Enter title here' => 'Enter model name here',
                'Excerpt' => "Byline",
                'Excerpts are optional hand-crafted summaries of your content that can be used in your theme.' => "Foobar"
            );
            break;
    }

    if (array_key_exists($text, $translation_array)) {
        return $translations->translate($translation_array[$text]);
    }

    return $translation;
}

The third translation isn’t working?

3 s
3

This description is generated by post_excerpt_meta_box() function and is not passed through any explicit filters. It is however echoed by translation-related _e() function and so passes through gettext filter (which from your question you are already familiar with).

As for limiting it to your CPT, I think current post type in admin is held in global $post_type variable you can check.

Leave a Reply

Your email address will not be published. Required fields are marked *