Guten Tag!
Ich möchte gerne den Kommentar-Bereich meiner Seite selbst anpassen. Auch die CSS-Klassen etc. Deshalb habe ich das hier in meine functions.php kopiert:
PHP
// Comments form input fields
function comment_form_changed_fields($fields){
$fields = array(
'author' => '<div class="comment-form-author"><label for="author">' . 'Name' . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></div>',
'email' => '<div class="commentz-form-email"><label for="email">' . 'Email' . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></div>', );
return $fields;
}
add_filter('comment_form_default_fields', 'comment_form_changed_fields');
// Comment form default fields
function comment_form_changed_defaults($defaults){
$fields = apply_filters('comment_form_default_fields', $fields);
$defaults = array(
'fields' => $fields,
'comment_field' => '<label for="comment">' . 'Comment' . '</label> <textarea id="comment" name="comment" aria-required="true" required="required"></textarea>',
'must_log_in' => '<div class="must-log-in">' . sprintf('You must be <a href="%s">logged in</a> to post a comment.', wp_login_url( apply_filters('the_permalink', get_permalink( $post_id)))) . '</div>',
'logged_in_as' => '<div class="logged-in-as">' . sprintf('<a href="%1$s" aria-label="Logged in as %2$s. Edit your profile.">Logged in as %2$s</a>. <a href="%3$s">Log out?</a>', get_edit_user_link(), $user_identity, wp_logout_url( apply_filters('the_permalink', get_permalink($post_id)))) . '</div>',
'comment_notes_before' => '<div class="comment-notes"><span id="email-notes">' . 'Your email address will not be published.' . '</span>'. ( $req ? $required_text : '' ) . '</div>',
'comment_notes_after' => '',
'id_form' => 'commentform',
'id_submit' => 'submit',
'class_form' => 'comment-form',
'class_submit' => 'submit',
'name_submit' => 'submit',
'title_reply' => 'Leave a Reply',
'title_reply_to' => 'Leave a Reply to %s',
'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">',
'title_reply_after' => '</h3>',
'cancel_reply_before' => '<small>',
'cancel_reply_after' => '</small>',
'cancel_reply_link' => 'Cancel reply',
'label_submit' => 'Post Comment',
'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
'submit_field' => '<div class="form-submit">%1$s %2$s</div>',
'format' => 'xhtml',
);
return $defaults;
}
add_filter('comment_form_defaults', 'comment_form_changed_defaults');
Alles anzeigen
Eigentlich funktioniert auch alles wunderbar so wie ich mir das vorgestellt habe. Es gibt nur ein Problem und zwar werden die Felder "Author" und "E-Mail" unter dem Textfeld ausgegeben und ich habe ehrlich gesagt keine Ahnung warum. Die Felder werden doch im Array gleich an erster Stelle eingefügt?!
Viele Grüße,
Sascha