最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

themes - How to edit the default comment title?

programmeradmin0浏览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?

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
Add a comment  | 

1 Answer 1

Reset to default 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;

}
发布评论

评论列表(0)

  1. 暂无评论