Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [comment-form]

This tag outputs a complete commenting form for use within a template. Most strings and form fields may be controlled through the $args array passed into the function, while you may also choose to use the comment_form_default_fields filter to modify the array of default fields if you'd just like to add a new one or remove a single field.

0
votes
1answer
19 views

How to remove the placeholder “comment” text from the comment field?

I have managed to remove the placeholders for both the "Name" and Email" fields but have not been able to remove the placeholder from the "Comment" field. For some reason I don't fully understand, the ...
1
vote
1answer
31 views

Remove “at” string from wordpress comment date

I'm using the following code to format the author's comment date and remove the time: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( 'd M Y', strtotime( $...
0
votes
0answers
36 views

All comment automatically added as spam comment, how to set that problem?

All comment(all post) automatically added as spam comment. Our same project set in two server, but in one server project blog comment working proper and another server project blog all comment added ...
1
vote
1answer
51 views

Global $post not working in OOP function WordPress

I added a custom field with comment form. Below is my code.First function return post id when using var_dump function.But the last function return NULL always. class Post_Rating_Public_Helper { ...
0
votes
0answers
116 views

How do I make comment-reply-button with <span> that takes to comment reply form on click

I do need your help. I'm actually designing my personal blog's theme and I got stuck when I could not code a working comment-reply-button with span element. I know you must be wondering why with a ...
0
votes
1answer
9 views

Author name length character limit?

In comments, I want to limit author names. For example, the author's name should be no more than 10 characters. I'm looking for a way to do this. Thank you very much in advance.
0
votes
1answer
30 views

Check if comment author has url

I wanted to add target=_blank to comment author link and also wanted to add redirection link to url. So here is what I did: <a href="site.com/go?url=<?php echo get_comment_author_url(); ?>" ...
1
vote
1answer
307 views

How to add consent checkbox in comment section

To fulfil the GDPR policy, I want to add a consent checkbox under the "Post Comment" section. I have followed the WpBeginner tutorial and put the following code in my Comment.php file // Now we will ...
0
votes
1answer
356 views

Comment form on custom page template

I have created a custom page template, but I don't know how to add the WordPress comment form to my <body> tag. I tried to include the following in my template.php file in the body tag, but the ...
1
vote
1answer
15 views

changing font size and font of a custom message added after comment

hi i have added a code in function file of the theme to show a default custom message after the user leaves a comment of the blogposts . it reads like this . add_filter('after_comment_text', '...
0
votes
0answers
37 views

Change “Logged in as a <name>. Log out?” link in comments form?

A portion of this question has been previously answered Here. I have used the filter-codes as written on the answer. But that only does the user-profile permalink part. The Log out option still stays....
0
votes
1answer
32 views

How to make comment reply available only for login members of a certain user roles only?

I use the default public WordPress comment system. But I want to make my comment reply only available to admin and author user roles. How do I achieve that?
1
vote
1answer
33 views

Notification if Comment Author Field is left empty. E.g. change input border colour

I am having a comment section on my website. The author comment field is required. Any idea how to display a notification for a user if author field is left empty after submitting the comment? ...
1
vote
1answer
24 views

Is it possible to force login for comments only on custom-post-type or the custom comment template?

I use a custom page template review-template for my custom post type reviews. And on my template, I use a custom comment form review-comments. Now... How do I enable login only for my review-comments ...
0
votes
0answers
84 views

Reply to comments and nested comments

i'm crating my first wordpress theme, and i'm dealing with the functionality of the comments, I don't really know how to make the replies work on a nested comment. This is what i have so far on my ...
0
votes
0answers
23 views

Modify comment form for custom post type

I am developing a plugin where I have to modify the default comment form of WordPress only for a custom post type. The modification includes changing texts such as Leave a reply,Comments(2) and also ...
0
votes
0answers
17 views

Load comment_form using javascript

I currently cache the page HTML after it has rendered and then serve this back to the users. If I view the page, the comment form will show "Logged in as Dan Hastings" and this gets saved to the cache....
0
votes
1answer
327 views

Full Front End, AJAX comment system and comment reply script

I am write a dynamic comment system, without page refreshing. The problem is, how do I move the "form" element to add sub comments? Like the comment-reply.min.js My workspace: <script type="text/...
0
votes
1answer
25 views

I'm unable to call img path using single quotes in an array?

I would like to call an image next to input field in wp comment form. But I'm unable to do that. I call image when '' <= single quotes doesn't exist. But I don't know how to call an image in single ...
0
votes
0answers
40 views

Admin Text Changes If Comment is from Custom Comment Template

I had made a custom comment template and in the custom comment template added an additional field to comment form called Question Title. In the admin of WordPress I found I can change admin text ...
1
vote
0answers
17 views

Assign author to comment from post edit page

How we can assign author to comment while creating this from post edit page. When i add new comment it always automatically assign login author to this comment. But i want there a select box that user ...
3
votes
1answer
428 views

Why does comment_reply_link launch the reply form at the wrong spot on the comment section?

I have this custom extended Walker_Comments class: class Custom_Comment_Walker extends Walker_Comment { var $tree_type = 'comment'; var $db_fields = array( 'parent' => 'comment_parent', '...
0
votes
1answer
106 views

Can not edit comment form

I'm trying to add author, email fields to comment form but the comment form does not change. It is always showing a default template with only the comment field and submit button. Could this be a ...
0
votes
1answer
55 views

Fetching Initials of the Commentator in the Wordpress Website

function getInitials($str) { $words = explode(" ", $str); $initials = null; foreach ($words as $w) { $initials .= $w[0]; } return $initials; //DT } echo $str = ...
1
vote
1answer
95 views

How do I add an extra field to comment form above the submit button?

I have added a custom subscribe field to the WooCommerce comment form. However, right now the field is above everything else. I am not sure how to move it to the bottom below the other fields. The ...
0
votes
1answer
17 views

Show this code if user has previously left a comment

Below is my code which is inserted into the comment template, It should show the comment form, if the user has never posted a comment on a particular post. Or if they have posted a comment on this ...
0
votes
1answer
15 views

How to call out the date of user's first comment?

For example, Sam's first comment was posted in 2010. How can I show this next to his name in the comment section? Like this: SAM [Joined since 2010] Update: Sorry for the unclear question. I am ...
0
votes
1answer
41 views

Removing(replacing) avtar in comments.php with some other HTML arrangements

<ol class="comment-list"> <?php wp_list_comments( array( 'style' => 'ol', 'short_ping' => true, ...
1
vote
0answers
20 views

comment form args are not translatable (customized comment form)

I customized the comment form by changing the 'args'. Short Example: $comments_args = array( 'title_reply' => esc_html__( 'Leave a comment', 'mytheme' ), 'title_reply_to' =&...
0
votes
1answer
50 views

WordPress comment submit button substitutes/options

$args = array( 'id_form' => 'commentform', 'class_form' => 'comment-form theme-comment-action', 'id_submit' => 'submit'...
1
vote
1answer
2k views

Create comments.php form of custom HTML code

One example of the comments.php is available here. I have created comments.php file in my theme folder. In my content.php my HTML for displaying comment form looks like this: <textarea name="name"...
0
votes
1answer
269 views

Change “logged in as a <username>” link in comments form

I want to change the "logged in as " link that displays in the reply comments form if logged in. The link is leading to wordpress profile in the backend, which it shouldn't. I want it to just a ...
0
votes
1answer
375 views

Remove the function which adds nofollow to links in comments

Not sure where the function is that does this but i need to remove it so all links in comments do not contain the rel="nofollow" attribute. I know i can use the comment_text filter to remove nofollow ...
0
votes
1answer
504 views

get_comments_number() returns 0

I am customizing a theme that has the following code to display comments: if ( have_comments() ) : ?> <h2 class="comments-title"> <?php printf( // WPCS: XSS OK. ...
0
votes
1answer
57 views

duplicate comment section functionality and call it something else for custom post types

I have a custom post type that I want people to leave messages but I dont want to call it "comment". How can I replicate the comment functionality and call it something else for a custom post type? I ...
1
vote
1answer
358 views

How to add attributes to the comment form tag?

How can I add attributes to form tag? Below is my code but it does not add the attributes I need: $args = array( 'title_reply'=>'', 'comment_notes_before' => '', 'logged_in_as' =>...
0
votes
1answer
696 views

How to add extra input fields to CPT's comment form?

I found filter hooks to add/modify the WordPress default comment form. But I couldn't find how to add extra fields to a CPT's (custom post type) comment form. I actually want to know the right way of ...
0
votes
1answer
229 views

Custom markup for the comment form

The issue The comment form, as i planned to design it, will use Bootstrap's input groups and probably input addons. Translating in bare coins, the needed markup for each input is like this: <...
0
votes
1answer
177 views

comment_for() Custom fields not visible when user is logged in

i have added some custom form fields using comment_for() as well as filtering the comment_form_default_fields and comment_form_defaults hook for the purposes of using a custom comment field as well as ...
1
vote
1answer
178 views

comment_form() Not changing the default class/id of elements

EDIT I am trying to change the class and id of the <form> element and well as the <input>/Submit button field using the comment_form() function. How ever it appears that various string ...
0
votes
1answer
155 views

Cannot display comment in page

I added some custom fields in comment, so i have a couple of more fields. from that form I can comment but am unable to display that comment. The comments are set to moderation so admin have to ...
1
vote
1answer
90 views

What functions does WordPress use for filtering / sanitizing comments?

We have some custom built comments (ones tied to custom post types, that we can't integrate with WP's comment system). But we want to filter the comments when they are submitted the way WP does and ...
1
vote
0answers
613 views

create comment box in woo-commerce shop order [closed]

i want to add comment box for Woo-commerce shop order and i am using the below script but its not working. function enable_comments_shop_post_type() { add_post_type_support( 'shop_order', '...
0
votes
1answer
238 views

How to pass settings to comment_form() if theme only uses comments_template()?

I have a theme which uses comments_template() to write a comment form and existing comments to a page. It appears that comments_template() calls comment_form() internally which writes the form that ...
0
votes
1answer
542 views

edit comments in front end

I build my custom comments template. And i realised tht edit comment is being done in back-end ( dashbord). Is there any way to enable edit comments in the front-end instead of in admin menu? Would be ...
1
vote
1answer
72 views

How can I get values count from wp_commentmeta?

I am using ACF Plugin in my wordpress site, and I have added radio buttons in comment form, like reactions. it's saving results in wp_commentmeta like this; it's working very good but I want to ...
1
vote
0answers
43 views

How to retain comment text on comment form after login/registration?

When users type some comment text and then click the login/register/sociallogin button next to the comment textarea and it registers them, it then redirects to the same page and totally erases their ...
2
votes
1answer
769 views

Change “logged in” link in (you must be logged in to post a comment)

I need to change the link for "logged in" to a user log in url instead of wp login url. I have checked /wp-includes/comment-template.php and that's what I found on line 2217 /** This filter is ...
0
votes
1answer
36 views

How to replace anonymous comment form with a registration form on wordpress?

I've been trying to convert the anonymous comment form to register users. However not only me but other people asked and there are no working answers on stackexchange. So I give up. Now I just want to ...
1
vote
1answer
119 views

How can I test why the comment hook is not working?

I am trying to perform an action after a comment is approved. What this action is, is to register the commenter automatically using register_new_user, using the commenter's name as the username, and ...