Child Theme functions.php
-
I changed the closed comments message in comments.php from ‘Comments have been disabled’ to ‘Comments for this post have are closed’.
As I just updated to 1.6.1 it obviously over wrote this change durning the upgrade. I was just about to go and change it again, but then wondered if I can make this change by using my child theme’s function.php.
Is this possible?
Yes, it is possible. Add this to your child theme’s
functions.php. (Add php markup if your functions.php file is empty)function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Comments have been disabled' => 'Comments for this post have are closed',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );Add
<?phpat the beginning and?>at the end of the code<?php
function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Comments have been disabled' => 'Comments for this post have are closed',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );
?>Added this, but no change. Cleared cache etc.
<?php
function graphene_filter_gettext( $translated, $original, $domain ) {
$strings = array(
'Comments have been disabled' => 'Comments for this post are closed',
);
if ( ! empty( $strings[$original] ) ) {
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}
add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );
?>Make sure Comments have been disabled resembles the original string in the parent theme’s comments file.
Also, remove the space in second line. I’ve added that to differentiate my first and second piece of code.
🙂 You are welcome!
Marking thread as resolved.
Viewing 9 posts - 1 through 9 (of 9 total)
- You must be logged in to reply to this topic.
