Home › Forums › Support › Add page title to “leave a comment” This topic has 6 replies, 3 voices, and was last updated 1 year, 11 months ago by David. Viewing 7 posts - 1 through 7 (of 7 total) Author Posts May 13, 2022 at 12:04 pm #2218913 Anders Nielsen How do I add the page title to the comments? I have found the filer, but need a little more. add_filter( ‘generate_leave_comment’,’tu_custom_leave_comment’ ); function tu_custom_leave_comment() { return ‘Leave a comment about PAGE-TITLE_HERE‘; } May 13, 2022 at 12:06 pm #2218915 Anders Nielsen Also if I can trigger this filter for only category “towns” How can I do that ? May 13, 2022 at 2:53 pm #2218998 YingStaff Customer Support Try this: add_filter( 'generate_leave_comment','tu_custom_leave_comment', 10, 2 ); function tu_custom_leave_comment() { $title = get_the_title(); $default = 'Leave a Comment'; if( in_category('towns')){ return 'Leave a comment about '.$title; } return $default; } May 13, 2022 at 10:45 pm #2219104 Anders Nielsen works… but I can’t add a “?” or any other text behind the title? add_filter( ‘generate_leave_comment’,’tu_custom_leave_comment’, 10, 2 ); function tu_custom_leave_comment() { $title = get_the_title(); $default = ‘Leave a Comment’; if( in_category(‘towns’)){ return ‘Leave a comment about ‘.$title; ? THIS FAILS } return $default; } May 14, 2022 at 8:02 am #2219562 DavidStaff Customer Support Hi there, try this: return 'Leave a comment about '.$title .'?'; or return 'Leave a comment about '. $title .'any text after must also be inside single straight quotes'; May 14, 2022 at 12:18 pm #2219702 Anders Nielsen Great … thanks May 15, 2022 at 3:36 am #2219970 DavidStaff Customer Support You’re welcome Author Posts Viewing 7 posts - 1 through 7 (of 7 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In