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've found tweaking some of the text in WordPress to be pretty easy by adding in the following function (in lieu of using a separate plugin):

add_filter( 'gettext', 'of_site_translations', 9999, 2 );
function of_site_translations( $translation, $text ) {
if ( $text == 'Posts' )
        return 'News Posts';
return $translation;
}

The issue I'm running into is (in my above example) while it will change Posts to News Posts in the WP Sidebar - areas that are dynamically created based on the post type labels; when you click on Posts from the sidebar and it leads you to a page that says Posts. Is there a way to override post type labels using this method? If so, any pointers that could push me along a bit? Really appreciate it, thanks!

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You could just rename the labels associated with that post type.

class News_Post_Type {
    const POST_TYPE = 'post';

    public static function init() {
        $post_obj = get_post_type_object('post');
        $post_obj->labels->name = __('News Post', 'textdomain');
        $post_obj->labels->singular_name = __('News Post', 'textdomain');
        // You can continue to rename all the label properties, this is just an example
    }
}

add_action( 'init', array( 'News_Post_Type', 'init' ) );
share|improve this answer
    
Wow! I had no idea this was possible. Was this something you also stumbled upon, or is there something in the codex I maybe missed about this? Really appreciate it! –  Zach Dec 22 '11 at 13:23
    
Had to do the same thing at work and it was suggestion from a co-worker. –  Kevin Langley Jr. Dec 22 '11 at 21:41

This depends on the theme you are using and how well it is using WordPress' string translations. Any text wrapped in translation strings can be modified using the gettext filter. Check this link for more information on translation strings -> http://codex.wordpress.org/I18n_for_WordPress_Developers

share|improve this answer

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.