The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Include post title ...
 
Share:
Notifications
Clear all

[Solved] Include post title in comment join text

6 Posts
2 Users
1 Reactions
899 Views
Posts: 15
 Jave
Topic starter
(@jave)
Eminent Member
Joined: 3 years ago

Hello,

 

is there a way to include the post title inside the comment join text (the placeholder)? 

 

I would like to change it dynamically according to the current post to something like:

 

"What are your thoughts about 'post title' ?" 

 

Maybe this is archivable with a simple snippet? 

 

Thanks in advance. 

5 Replies
Posts: 15
 Jave
Topic starter
(@jave)
Eminent Member
Joined: 3 years ago

Got it working with this:

 

add_filter("wpdiscuz_phrase", function ($phrase, $key, $args) {
    if ($key === "wc_comment_join_text") {
	$title = get_the_title(get_queried_object_id());
        $phrase = str_replace("Kommentar", "What are your thoughts about $title ?" , $phrase);
    }
    return $phrase;
}, 10, 3);

 

But now there results another question out of it: As the placeholder is the same like in reply to textarea it doesn't fit anymore. How can I hide the placeholder only in reply to form but keep it in the main comment form?

1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7617

@jave,

You can use the CSS code: 

#wpdcom form.wpd_comm_form.wpd-secondary-form-wrapper .ql-editor::before{ 
    display: none;
}

Put the code in the Top Admin Bar > Customize > Additional CSS > "Additional CSS" textarea, save it, delete all caches and check again.

Posts: 15
 Jave
Topic starter
(@jave)
Eminent Member
Joined: 3 years ago

Thanks, working! Last question: Is it also possible to change the submit button text only for replies?

1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7617

@jave,

You should use some JS code like this: 

jQuery(document).ready(function(){
      jQuery('#wpdcom #wpdiscuz_hidden_secondary_form input[type="submit"]').attr("value", "Your text");
});

This article should be helpful for you: https://www.collectiveray.com/add-javascript-to-wordpress

Change the red marked value as you like. 

Posts: 15
 Jave
Topic starter
(@jave)
Eminent Member
Joined: 3 years ago

Great, thanks alot. Everything solved! 🙂

Share: