Got the way to change the labels everywhere for the post_type "Post". For a customer site, I need to use the WordPress comments. Just need to change the label from "Comments/Comment" to "Review" everywhere. But where for post_type "Post" we can use $wp_post_types;
, what can we use for comments?
I tried with $wp_comments
, $wp_comment
etc. but failed.
How can I do it?
PS: I don't want a way to translate all the strings etc. Just need a way like the link pasted above. And not just the menu labels, I need to change them everywhere, so that under the post writing page, in the checkbox saying "All comments" would also change.
Got the way to change the labels everywhere for the post_type "Post". For a customer site, I need to use the WordPress comments. Just need to change the label from "Comments/Comment" to "Review" everywhere. But where for post_type "Post" we can use $wp_post_types;
, what can we use for comments?
I tried with $wp_comments
, $wp_comment
etc. but failed.
How can I do it?
PS: I don't want a way to translate all the strings etc. Just need a way like the link pasted above. And not just the menu labels, I need to change them everywhere, so that under the post writing page, in the checkbox saying "All comments" would also change.
You can try the gettext
filter.
According to the Codex:
This filter hook is applied to the translated text by the internationalization functions (__(), _e(), _x(), etc.). This filter is always applied even if internationalization is not in effect, and if the text domain has not been loaded.
Here's an example:
function custom_gettext( $translated_text, $untranslated_text, $domain )
{
if( FALSE !== stripos( $untranslated_text, 'comment' ) )
{
$translated_text = str_ireplace( 'Comment', 'Review', $untranslated_text ) ;
}
return $translated_text;
}
is_admin() && add_filter( 'gettext', 'custom_gettext', 99, 3 );
to change the strings containing Comment
to Review
(ignoring case).
You can adjust the replacements to your needs.
A more brute simple hack method is to use jQuery to find target string Comment
and replace it with Review
. To do this you can check out this thread:
https://stackoverflow.com/questions/8146648/jquery-find-text-and-replace
Example:
$("#container p:contains('Comment')").text("Review");
To include this script in your WordPress headers you can add an action and function in your theme's functions.php. For more details, check out:
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head http://codex.wordpress.org/Function_Reference/wp_enqueue_script
The only way to change all the places with the word "comment/s" to "review/s" is by creating a new translation file for the core, relevant plugins (akismet) and the theme. There are just too many of them to handle in any other way.
The difference between comments and posts is that you can't register new comment types (no api for that) and that is the reason there is no simple way to handle the removal of comments in the same way as posts were removed in the question you pointed to.