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?
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;
}
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 .?
hi is it not possible???
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;
}
hi the new code returned the following error
syntax error, unexpected 'wpd' (T_STRING)
I just updated the code above, please change it.
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 .
I'm sorry but I don't have other solution. You should find some CSS socialist to do a custom styling for this case.
oh its okay .thank you very much .