16

I know this is quite an old post and maybe this could help someone. You can replace the class of an element using add_filter(); Here's an example: // filter to replace class on reply link // class name function name add_filter('comment_reply_link', 'replace_reply_link_class'); function replace_reply_link_class($class){ $class = ...


13

From WordPress Version 4.1 (trac ticket #20446) it's now added to pass your own class as an argument of comment_form($args) using 'class_submit' array key: $args = array( 'class_submit' => 'btn btn-default' ); No need to do extra hard work. (Edited the Codex too) :)


11

We can use comment_form function's submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> You can change your code like this. $comments_args = array( .... 'submit_button' => '<div class="form-group"> <input name="%...


8

You shouldn't copy that file, precisely because it is too bulky. About half of it is implementation of submission form, which was entirely replaced with comment_form() function around that time. So the answer why was it deprecated is roughly: Newer code is more compact Markup belongs in theme For better and more relevant comments.php example look at core ...


6

There are obviously a number of ways to accomplish this. For example, to move the comment field to the bottom of the form you would use code like this: add_filter( 'comment_form_fields', 'move_comment_field' ); function move_comment_field( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $...


6

I was facing same problem and was searching for solution i found the solution Open your function.php file and past below code: function comment_validation_init() { if(is_single() && comments_open() ) { ?> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></...


6

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = '<p><...


5

In the Settings >> Discussion Screen, there is a options tick box, 'Enable threaded (nested) comments [X] levels deep'. From there you can tick to activate threaded comments and set how many levels deep to a maximum of 10. You should also check if your theme has the following piece of code, should normally be in the functions.php template of your theme. ...


5

When we post an empty anonymous reply, we get the following errors: The part of BBPress that's responsible for handling this, is the bbp_new_reply_handler() function, in the file /bbpress/includes/replies/functions.php. It contains these lines that are of interest to us: // User is anonymous if ( bbp_is_anonymous() ) { // Filter ...


5

Comment.php The way I see your comment.php seems messy and more complex than it needs to be, you can post this piece of code to in your comment.php and it should work okay. <?php /** * If the current post is protected by a password and * the visitor has not yet entered the password we will * return early without loading the commend */ if (...


5

Please place below code in your theme's functions.php file and it will wrap the submit button inside div: // define the comment_form_submit_button callback function filter_comment_form_submit_button( $submit_button, $args ) { // make filter magic happen here... $submit_before = '<div class="form-group">'; $submit_after = '</div>'; ...


4

Filter comment_form_defaults and add your code to the textarea. Sample code, not tested: add_filter( 'comment_form_defaults', 'wpse_120049_extend_textarea' ); function wpse_120049_extend_textarea( $args ) { $args['comment_field'] .= '<p>Extra text.</p>'; return $args; }


4

Ok I feel stupid now. The problem was that for whatever reason some of the posts had comments disabled. I did not know that the only place where they could be toggled was under "Quick Edit". Problem solved...


4

We could rewrite: wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); with the null walker parameter: wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); which means we are using the default Walker_Comment class: wp_list_comments( array( 'walker' ...


4

This code will allow you to customize the comment field labels and will move the comment form below the fields. Add the code to your functions.php or to a plugin. To change the labels, modify the Name CUSTOMIZED, Email CUSTOMIZED, and Website CUSTOMIZED, and Comment * CUSTOMIZED text. /** * Customize comment form default fields. * Move the comment_field ...


3

Open comments.php file inside your theme's folder <?php if ( comments_open() ) : ?> <?php $fields = array( 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'responsive' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="...


3

Version #1 The following seems to work for the Twenty Fifteen theme: /** * Display the comment form via shortcode on singular pages * Remove the default comment form. * Hide the unwanted "Comments are closed" message with CSS. * * @see http://wordpress.stackexchange.com/a/177289/26350 */ add_shortcode( 'wpse_comment_form', function( $atts = array(), ...


3

This is possible using the comment_post action, and the GFAPI class which handles entries in WordPress. What you need to first is add using comment_form_default_fields a field which is a checkbox. function add_to_email_list_field($fields) { $fields['add-to-email'] = '<p class="comment-form-public"> <input id="addtoemail" name="addtoemail"...


3

If you need to modify the max depth, you could use the thread_comments_depth_max filter: /** * Set max comments depth to 15 on the discussion settings page */ add_filter( 'thread_comments_depth_max', function( $max ) { return 15; } ); then the dropdown on the discussion settings page will show the range 1 - 15. But I can imagine very deep comment ...


3

I wonder if you mean this kind of approach: add_filter( 'init', function() { $u = wp_get_current_user(); if( $u->exists() && in_array( 'banned', $u->roles, true ) ) add_filter( 'comments_open', '__return_false' ); } ); where we check if the current user has the custom banned role. If that's the case then we force all ...


3

It seems that WordPress handles the comment field separately than the other fields. If you look at comment_form() in wp-includes/comment-template.php, you can see this. It's possible to set $defaults['comment_field'] to false in alpha_comments_defaults() then add the comment field markup to $fields['comment_field'] in alpha_comments_fields() in the desired ...


3

Any comments_template filter should return an absolute filepath to the comments template - use comment_form_defaults and set the class_form argument: add_filter( 'comment_form_defaults', function ( $args ) { $args['class_form'] = 'my form classes'; return $args; });


3

No, it is not a bug. This is how core handles it. If you look into /wp-includes/comment-template.php, you'll notice, that the only difference in <form> element, is novalidate attribute added, when current_theme_supports( 'html5', 'comment-form' ) is true. But there are other html elements within comment form, which are affected by theme's choice of ...


3

Use this function rather than comment_form() function validate_comment_form(){ ob_start(); comment_form(); echo str_replace('<form','<form attribute="value" ',ob_get_clean()); }


3

Most likely, the 'at' is coming from the value of $comment->comment_date. If that is the case, and since we have to do with string, you could pass it from str_replace first, in order to remove the ' at', like: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( 'd M Y', strtotime( str_replace(" at", "", $comment->...


2

I was searching for the same solution and at last i found the solution, the below code worked perfectly for me, I wanted to add "btn btn-primary" class to the submit button in comment form. ob_start(); comment_form( $args ); $form = ob_get_clean(); $form = str_replace('class="comment-form"','class="comment-form"', $form); echo str_replace('id="submit"','...


2

One Trick Pony answered the question, here's his solution: jQuery('#comment_form')[0].encoding = 'multipart/form-data'; And here's a jsFiddle of it.


2

I realized that comment-reply.js is not loaded and it fixed the issue. Could someone explain? I have no idea what happened. So the fix was adding wp_enqueue_script( 'comment-reply' ); to my plugin code.


2

Don't build your own form and don't modify comments.php - it's purpose is little bit different and I don't think you should include it inside sidebar. Just put comment_form function call in your sidebar template. It takes 2 parameters: args and post_id. So you can do it like this: $args = array( ... // your custom arguments (you can leave it empty ); ...


2

I'll answer myself. Add the following somewhere in functions.php or make it into a plugin: add_action( 'comment_form_logged_in_after', 'psot_comment_form_avatar' ); add_action( 'comment_form_after_fields', 'psot_comment_form_avatar' ); function psot_comment_form_avatar() { ?> <div class="comment-avatar"> <?php $current_user = ...


Only top voted, non community-wiki answers of a minimum length are eligible