- This topic has 12 replies, 2 voices, and was last updated 5 years, 9 months ago by Tom.
-
AuthorPosts
-
July 25, 2018 at 4:28 am #632292Xavi
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?
July 25, 2018 at 10:25 am #632610TomLead DeveloperLead DeveloperThat’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);
July 25, 2018 at 2:11 pm #632744XaviHi
Yes, it is extrange but it doesn’t work π
I’m using Code Snippets.
Another idea about why it is not working?
ThanksYou 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);
July 25, 2018 at 8:03 pm #632880TomLead DeveloperLead DeveloperTry 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; }
July 26, 2018 at 2:11 am #632992Xaviπ Same output with your latest code.
Now your suggestion is active in the web in case you need to check something.
Thanks
July 26, 2018 at 9:18 am #633342TomLead DeveloperLead DeveloperThat’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?
July 26, 2018 at 2:07 pm #633539XaviStrange issue, I have deactivate all plugins (except code snippets)and nothing changed.
How can I debug it?July 26, 2018 at 8:57 pm #633702TomLead DeveloperLead DeveloperCan you try removing this line from the parent theme
comments.php
file?: https://github.com/tomusborne/generatepress/blob/2.1.3/comments.php#L119July 27, 2018 at 12:05 am #633771XaviHi 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
July 27, 2018 at 5:51 am #633955XaviI 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
July 27, 2018 at 10:05 am #634186TomLead DeveloperLead DeveloperI don’t see anything wrong with that function – nice find!
I’ll get the original issue fixed in GP 2.2 π
Thanks!
July 28, 2018 at 2:36 am #634504XaviThanks for your support Tom!!!
July 28, 2018 at 7:19 am #634652TomLead DeveloperLead DeveloperNo problem π
-
AuthorPosts
- You must be logged in to reply to this topic.