Hej
Jeg vil høre hvilken function jeg skal bruge, hvis jeg gerne vil ændre class i textarea, og input, det er i min blog kommentar.
Syntes ikke rigtig jeg kan finde den, har prøvet med:
<?php esc_textarea( array(
'comment-form-email' => 'form-text text-muted'
)); ?>
Men den er vist kun til text inden i.
Med venlig hilsen
Morten
Class ændring så bootstrap kan træde ind
-
MortenMoeller
- Begynder
- Indlæg:5
- Tilmeldt:9. okt 2017, 09:56
-
MortenMoeller
- Begynder
- Indlæg:5
- Tilmeldt:9. okt 2017, 09:56
Re: Class ændring så bootstrap kan træde ind
<?php esc_textarea( array(
'comment-form-email' => 'form-control'
)); ?>
lige en rettelse
'comment-form-email' => 'form-control'
)); ?>
lige en rettelse
-
MortenMoeller
- Begynder
- Indlæg:5
- Tilmeldt:9. okt 2017, 09:56
Re: Class ændring så bootstrap kan træde ind
Her lige prøvet med
comments_template( array(
'comment-form-email' => 'form-control',
));
comments_template( array(
'comment-form-email' => 'form-control',
));
-
MortenMoeller
- Begynder
- Indlæg:5
- Tilmeldt:9. okt 2017, 09:56
Re: Class ændring så bootstrap kan træde ind
Næsten på rette vej
add_filter( 'comment_form_defaults', function ( $args ) {
$args['class_form'] = 'form-control';
return $args;
});
Men får kun fat i formen ikke input og textarea
add_filter( 'comment_form_defaults', function ( $args ) {
$args['class_form'] = 'form-control';
return $args;
});
Men får kun fat i formen ikke input og textarea
-
MortenMoeller
- Begynder
- Indlæg:5
- Tilmeldt:9. okt 2017, 09:56
Re: Class ændring så bootstrap kan træde ind
Her fandt jeg en metode mangler bare at få text area til at virke
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
function bootstrap3_comment_form_fields( $fields ) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
$fields = array(
'comment' => '<div class="form-group comment-form-comment">' . '<label for="comment">' . __( 'Comment' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="comment" name="comment" type="textarea" value="' . esc_attr( $commenter['comment'] ) . '" cols="45" rows="8" maxlength="65525"' . $aria_req . ' /></div>',
'author' => '<div class="form-group comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="10"' . $aria_req . ' /></div>',
'email' => '<div class="form-group comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="10"' . $aria_req . ' /></div>',
'url' => '<div class="form-group comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
'<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="10" /></div>'
);
return $fields;
}
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
function bootstrap3_comment_form_fields( $fields ) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
$fields = array(
'comment' => '<div class="form-group comment-form-comment">' . '<label for="comment">' . __( 'Comment' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="comment" name="comment" type="textarea" value="' . esc_attr( $commenter['comment'] ) . '" cols="45" rows="8" maxlength="65525"' . $aria_req . ' /></div>',
'author' => '<div class="form-group comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="10"' . $aria_req . ' /></div>',
'email' => '<div class="form-group comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input class="form-control" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="10"' . $aria_req . ' /></div>',
'url' => '<div class="form-group comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
'<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="10" /></div>'
);
return $fields;
}

