Customize Wordpress Comments Form Template CSS Style HTML Submit Button / Customize Default Gravatar Wordpress

  • Download Gist
customize_wordpress_comments_function.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
<?php
// Customize Worpress Comments Form Template HTML
add_filter('genesis_comment_form_args','custom_comments_function'); /*change the comment_form_args for your theme - this is for genesis, which is a "hooked" theme.*/
function custom_comments_function() {
 
global $current_user;
get_currentuserinfo();
 
$args = array(
'fields' => array(
'author' => '<BR />' .
'<input id="author" name="author" type="text" class="required" placeholder="Your Name" minlength="2" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" tabindex="1"' . $aria_req . ' />' .
( $req ? '<span class="required">*</span>' : '' ) .
'',
'email' => '<p class="comment-form-email">' .
'<input id="email" name="email" type="text" class="required" placeholder="Your Email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" tabindex="2"' . $aria_req . ' />' .
'<label for="email">' . __( '<span class="breadcrumb-lead">YOUR EMAIL ADDRESS IS NOT PUBLISHED & REMAINS PRIVATE.</span>', 'genesis' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'</p>',
'url' => ''
),
'comment_field' => '<p class="comment-form-comment">' .
'<textarea id="comment" name="comment" cols="45" rows="8" tabindex="4" aria-required="true"></textarea>' .
'</p>',
'title_reply' => __( 'Add a comment, a question:', 'genesis' ), /*change for your theme, and for what you want your comments header to say*/
'comment_notes_before' => '<small><span class="muted" style="font-style: italic;">All comments are moderated.</span></small>',
'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( '<small>You are currently logged in as <a href="%1$s">%2$s</a> ... <a href="%3$s" title="Log out of this account">Log out?</a></small>' ), admin_url( 'profile.php' ), $current_user->user_login, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
'label_submit' => __( ' Don\'t Be Shy, Submit Your Comment Now! ' ),
'class_submit' => __( 'btn btn-info' ), /*you can't style the button without changing a core file (or using a plugin) which kinda sucks, but this is where you would express the button styling*/
'comment_notes_after' => '',
);
return $args;
}
 
// Change default comments gravatar to a custom image
add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatarPurple = get_bloginfo('template_directory') . '/images/purple_user_avatar.png'; /* use ftp to upload your custom avatar to the images dir */
$avatar_defaults[$myavatarPurple] = "Purple User Avatar";
/* now choose your new default avatar in wordpress > settings > discussion */
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.