Notifications
Clear all

default field added with content already added

10 Posts
3 Users
0 Likes
1,935 Views
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

hi ,

i would like to add a default field to add to every comment which should not be shown in comment form but added to comment when it is displayed on the website

like a disclaimer message "the comment added here is  by the author and my website doesnt have any take on this .. such and such etc" i want this message to be added after every comment by default . is it possible ?any workaround for this?


   
Quote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5924
 

Hi nikhilgkurup,

Put the following code in your current active theme functions.php file:

add_filter('comment_text', 'add_custom_content');
function add_custom_content($comment_text) {
if ($comment_text) {
$comment_text .= "<div>the comment added here is by the author and my website doesn't have any take on this .. such and such etc</div>";
}
return $comment_text;
}

 


   
ReplyQuote
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

hi thankyou for that  ......

but now the default comment is added with the actual comment .but i would like it to be after every fields . i have attached an image to make it more clear . i would like it to show after the time of journey field and before the like button and all .. is it not possible .?

comemntwpdiscuz

   
ReplyQuote
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

hi is it not possible???


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4174
 

Hi @nikhilgkurup,

Probably you should use wpdiscuz_after_comment_text hook. Please remove the old code and try this one:

add_filter('wpdiscuz_after_comment_text', 'wpdiscuz_add_custom_content');
function wpdiscuz_add_custom_content( $comment_text, $comment ) {
        if ($comment_text) {
                $comment_text .= "<div class='wpd-custom-text'>the comment added here is by the author and my website doesn't have any take on this .. such and such etc</div>";
        }
        return $comment_text;
}

   
ReplyQuote
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

hi the new code returned the following error

syntax error, unexpected 'wpd' (T_STRING)


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4174
 

I just updated the code above, please change it.


   
ReplyQuote
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

thank you very much it works now . .. is it possible to have any adjustment with the font size of this text  . now the disclaimer message is highlighted more than  the comment texts . i would like the default disclaimer be of small font size than the others or at least of the same size of added field entries . like the one i have encircled in the photo attached .in the pic the field entry 'ernakulam' is less in size than the default message added .

wpdicuz comment default

   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4174
 

I'm sorry but I don't have other solution. You should find some CSS socialist to do a custom styling for this case.


   
ReplyQuote
(@nikhilgkurup)
Active Member
Joined: 6 years ago
Posts: 14
Topic starter  

oh its okay .thank you very much . 


   
ReplyQuote
Share:
Scroll to top