1

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?

    <?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.

2

1 Answer 1

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
2
  • I thought about this, but how can I keep from having to re-add this to comments.php everytime I upgrade wordpress or my theme? Commented Aug 6, 2011 at 6:13
  • WordPress does not touch theme files when it upgrades, your theme on the other hand depends but typically they do not over-write anything you added, you can safeguard this rather easily but writing a custom functions file like my_comment_function.php and simply include it in functions.php.
    – Wyck
    Commented Aug 6, 2011 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.