Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the "Featured Image" meta box which allows you to attach a secondary thumbail to a post. The title for this box is defined in the Wordpress codebase like so:

__('Featured Image')

Which looks to be a wrapper for the translate methods. I'm wondering how to change this text without having to do any translation files. Is it as simple as an action or filter hook?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Sure, the gettext filter does exactly what you require.

Here's some code that should work out of the box:

function wpse31449_translate_my_stuff($translation, $text, $domain) {
    if ($text == 'Featured Image')
        return 'Post Image';
    return $translation;
}
add_filter( 'gettext', 'wpse31449_translate_my_stuff', null, 3 );

Note: if the translation is retrieved with a gettext context (_x() and _ex()) then the gettext_with_context filter has to be hooked to, which passes 4 arguments - the translation, the original string, the context and the domain to your filter.

Let me know if the answer is clear and/or how I can further improve it.

share|improve this answer
    
Incredibly clear, and exactly what I was looking for. Thanks! –  typeoneerror Oct 19 '11 at 5:41
    
Here's what I ended up doing, btw. typeoneerror.com/articles/post/… –  typeoneerror Oct 19 '11 at 6:39
1  
Great post, well done! I like how you found an application for it. Make sure you mention our community that helped you figure this and any other questions that you may have had or will have, though wink wink –  soulseekah Oct 19 '11 at 6:48
1  
Oh, good call. Linked ya up. :) –  typeoneerror Oct 19 '11 at 15:10
    
I meant the WPStackExchange community in general, but big thanks, Benjamin, great blog, btw. –  soulseekah Oct 20 '11 at 6:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.