0

I want a code so when there are (or is) two comments on the post, it automatically changes the title to "Add Your Voice To The Topic!".

What is the code for this?

2
  • When you ask questions, please search SE to see if there are already answers to your questions, if not take the time to try to resolve this problem and then share your code for advice - wordpress.stackexchange.com/a/337368/7968
    – Q Studio
    Commented Jan 13, 2021 at 18:07
  • Thank you. Yes I usually search before asking. I think my question is different. I am not looking to just change the default title. And I don't want to limit it to specific pages. I want to keep the current title, and change it when there two comments or more on the post. so from the third comment, it shows the new title.
    – joseph
    Commented Jan 13, 2021 at 18:19

1 Answer 1

0

You can probably try somthing like this - untested...

add_filter('comment_form_defaults', 'wpse379939_comment_form_modification');
function wpse379939_comment_form_modification($defaults){

    // check if we have 2 or more comments..
    if ( get_comments_number() >= 2) {

        $defaults['title_reply'] = __('Add Your Voice To The Topic!');   

    }

    return $defaults;

}
1
  • unfortunately it didn't work. it shows the number of comments only.
    – joseph
    Commented Jan 16, 2021 at 20:22

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.