Archived topic
Adding extra text in comments
12 replies · Started by Xavi on July 25, 2018
Hi
I'm trying to add some text after the submit comment button but it is not shown.
function change_note_after_comment_form($defaults) {
$defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>';
$defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
return $defaults;
}
add_filter('comment_form_defaults', 'change_note_after_comment_form');
"text 1" is correctly shown if I'm logged but "text 2" isn't shown neither i'm logged or not.
any ideas?
That's strange - should be working.
Try replacing this:
add_filter('comment_form_defaults', 'change_note_after_comment_form');
With this:
add_filter('comment_form_defaults', 'change_note_after_comment_form', 99);
Hi
Yes, it is extrange but it doesn't work :-(
I'm using Code Snippets.
Another idea about why it is not working?
Thanks
You can see an example in https://vivirmindfulness.com/comer/aceptacion
Now I have this active:
function change_note_after_comment_form($defaults) {
$defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>'; //test to see if it is doing something
$defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
return $defaults;
}
add_filter('comment_form_defaults', 'change_note_after_comment_form',99);
Try this:
add_action( 'after_setup_theme', 'tu_change_comment_fields' );
function tu_change_comment_field() {
add_filter('comment_form_defaults', 'change_note_after_comment_form',99);
}
function change_note_after_comment_form($defaults) {
$defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>'; //test to see if it is doing something
$defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
return $defaults;
}
:-( Same output with your latest code.
Now your suggestion is active in the web in case you need to check something.
Thanks
That's so strange - it's just a core WordPress filter, so it should work.
Perhaps one of your plugins is overwriting it? Can you try deactivating them to rule out a conflict?
Strange issue, I have deactivate all plugins (except code snippets)and nothing changed.
How can I debug it?
Can you try removing this line from the parent theme comments.php file?: https://github.com/tomusborne/generatepress/blob/2.1.3/comments.php#L119
Hi Tom,
I have edited the file /wp-content/themes/generatepress/comments.php . I haven't a child theme.
And it works!!!!
It seems that the theme file overwrites Code snippets.
Now that the reason is identified. There is any form to avoid changes in the comments.php file?
I'm trying to avoid a child theme because I have never done :-)
With comment_notes_after I can add some text after the comment box but I prefer to add the text after the submit button. Is it possible?
Thanks
I have tryed this code
add_action( 'comment_form_after', 'tu_change_comment_fields' );
function tu_change_comment_fields() {
echo '<p class="comment_text_after"> text after button xavi </p>';
}
To add some text after the submit button.
It works, but, as I'm novice ;-), I don't know if it is the correct way to do it or it could have collateral damages.
Is it correct?
Thanks
I don't see anything wrong with that function - nice find!
I'll get the original issue fixed in GP 2.2 :)
Thanks!
Thanks for your support Tom!!!
No problem :)