- This topic has 7 replies, 2 voices, and was last updated 4 years, 8 months ago by Leo.
-
AuthorPosts
-
July 28, 2019 at 3:35 pm #969580Melissa
I would like to replace “1 thought on “Title”” with “1 Comment”.
I would also like to remove the time but leave the date on the comments.What is the best way to do this?
July 28, 2019 at 6:15 pm #969625LeoStaffCustomer SupportHi there,
Give this PHP snippet a shot:
add_filter( 'generate_comment_form_title', function() { $comments_number = get_comments_number(); return sprintf( // WPCS: XSS OK. /* translators: 1: number of comments */ esc_html( _nx( '%1$s comment', '%1$s comments', $comments_number, 'comments title', 'generatepress' ) ), number_format_i18n( $comments_number ), get_the_title() ); } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps 🙂
July 28, 2019 at 8:38 pm #969681MelissaI got the following error message:
The code snippet you are trying to save produced a fatal error on line 1:
Uncaught Error: Call to undefined function filter() in /home/mkuhnell/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(213) : eval()’d code:1 Stack trace: #0 /home/mkuhnell/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(213): eval() #1 /home/mkuhnell/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(259): Code_Snippets_Edit_Menu->validate_code(Object(Code_Snippet)) #2 /home/mkuhnell/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(122): Code_Snippets_Edit_Menu->save_posted_snippet() #3 /home/mkuhnell/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(99): Code_Snippets_Edit_Menu->process_actions() #4 /home/mkuhnell/public_html/wp-includes/class-wp-hook.php(286): Code_Snippets_Edit_Menu->load(”) #5 /home/mkuhnell/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array) #6 /home/mkuhnell/public_html/wp-includes/plugin.php(465): W
July 29, 2019 at 8:23 am #970213LeoStaffCustomer SupportHmm I just tested with Code Snippets without any errors:
https://www.screencast.com/t/aT9ddqqyCan you double-check if everything is copied and pasted correctly? make sure it’s the only snippet n there as well.
July 29, 2019 at 8:59 am #970266MelissaOK, I re-pasted and it’s working (not crashing). However, now it is showing “1 comment on “Title”” and I want it to not show the “on title”. Just the number of comments.
And I want to remove the time stamp on comments.
Thanks so much for helping!
July 29, 2019 at 10:28 am #970331LeoStaffCustomer SupportUpdated the code above to remove the title.
Removing the time stamp is quite complicated but Tom explained it in this post:
https://generatepress.com/forums/topic/removing-date-time-from-comments/#post-250025July 29, 2019 at 11:39 am #970363MelissaYour code worked perfectly. How silly that it’s so hard to remove the time stamp. I’ll work on that.
Thanks!
July 29, 2019 at 11:59 am #970379LeoStaffCustomer SupportNo problem 🙂
Let me know if you need more info.
-
AuthorPosts
- You must be logged in to reply to this topic.