Change comments form title on a page by page basis

I’m looking to change the comments form title (my theme defaults this to “Leave a Comment” or “Leave a reply to”).

I thought perhaps I could add a hook to comment_form_defaults but my snippet below isn’t working… any thoughts?

Read More
    <?php 
add_filter('comment_form_defaults', 'askQuestion');

function askQuestion($defaults) {
  $defaults['title_reply'] = 'Ask a Question';
  $defaults['title_reply_to'] = 'Your text %s';
  return $defaults;
}
?>

This is being added to the HTML editor of the page editor within wordpress. We are using the ExecPHP plugin to compile code within posts/pages. We are looking for a way to do this on just this page, not every comment form on our blog.

Related posts

Leave a Reply

1 comment

  1. Add the code to your comment template file or your functions.php with a page conditional. The comments file depends on your theme, by default it is comments.php , but it could be named anything, you need to look at your theme’s code.

    For example if it’s the contact page,

      if (is_page('Contact'))
        // do something