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?
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?
Share Improve this question edited Jan 13, 2021 at 18:02 joseph asked Dec 16, 2020 at 14:08 josephjoseph 135 bronze badges 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/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
Reset to default 0You 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;
}