Change “Comments” form (bis)
-
Hello everybody! Hello @alexmoise,
In wordpress, using Divi theme, i try to reorganize in a compact way my comment template… wihtout any success. I try the comments.php, the comment-template.php and a lot of others php files without success.
Goal: align on the same line, for the comment aera, the name (comment-form-author), the url and the email. To save space.Source for help:
– https://www.ads-software.com/support/topic/change-comments-form/
– https://divi.space/css-and-jquery/how-to-edit-the-divi-comments-section-without-a-plugin/And try to adapt this code from Alex, but can’t find a way to display them in a table with 3 columns.
// comment form fields re-defined: add_filter( 'comment_form_default_fields', 'mo_comment_fields_custom_html' ); function mo_comment_fields_custom_html( $fields ) { // first unset the existing fields: unset( $fields['comment'] ); unset( $fields['author'] ); unset( $fields['email'] ); unset( $fields['url'] ); // then re-define them as needed: $fields = [ 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'A CUSTOM COMMENT LABEL', 'noun', 'textdomain' ) . '</label> ' . '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'A CUSTOM NAME LABEL', 'textdomain' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __( 'A CUSTOM EMAIL LABEL', 'textdomain' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __( 'A CUSTOM WEBSITE LABEL', 'textdomain' ) . '</label> ' . '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', ]; // done customizing, now return the fields: return $fields; } // remove default comment form so it won't appear twice add_filter( 'comment_form_defaults', 'mo_remove_default_comment_field', 10, 1 ); function mo_remove_default_comment_field( $defaults ) { if ( isset( $defaults[ 'comment_field' ] ) ) { $defaults[ 'comment_field' ] = ''; } return $defaults; }
In advance, thanks a lot for your help!!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Change “Comments” form (bis)’ is closed to new replies.