JiveDig
11/6/2013 - 3:07 PM

Change custom post type "Enter title here" text

Change custom post type "Enter title here" text

// Change the "Enter title here" to "Enter book title here" for Books
add_filter('gettext', 'book_custom_rewrites', 10, 4);
function book_custom_rewrites($translation, $text, $domain) {
	global $post;
        if ( ! isset( $post->post_type ) ) {
            return $translation;
        }
	$translations = &get_translations_for_domain($domain);
	$translation_array = array();
 
	switch ($post->post_type) {
		case 'books': // enter your post type name here
			$translation_array = array(
				'Enter title here' => 'Enter book title here'
			);
			break;
	}
 
	if (array_key_exists($text, $translation_array)) {
		return $translations->translate($translation_array[$text]);
	}
	return $translation;
}