This topic has 7 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #157386
     joy
    Participant

    How do I change the labels on the comment form? I do not want to use a plugin, I want to hardcode the changes. Thank you.

    #157420
     Laura
    Moderator

    Hello, change them like how? The text or the style?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #157422
     joy
    Participant

    I would like to remove the “comment“ label but keep the rest of the labels. If you can point me in the right direction, I’m sure I could figure out our, I just don’t want to use another plug in.

    #157646
     Laura
    Moderator

    Hello, just add this to style.css of child theme

    COPY CODE
    
    p.comment-form-comment label {
        display: none !important;
    }
    

    Let me know if it helps 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #157652
     joy
    Participant

    I didn’t ask to remove them. I want to change what they say, without the translation plugin. There should be a way to target the core file and hardcode the changes.

    For example, I want to change the word “comment” to the word “reply”.

    #157824
     Laura
    Moderator

    Hello, it is easier to use the plugin we do not suggest to edit so many files as it can be a problem for future updates.
    The comment word you see its default wordpress, the one that kleo has is above it, and can be found at comments.php

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #157855
     joy
    Participant

    If you use a child theme you can update files without any conflicts with future releases. I managed to find what I needed. If anyone else is interested the text can be changed in the functions.php file, just be sure you don’t overwrite Kleo files and use a child theme.

    Thanks.

    #157914
     Radu
    Moderator

    Hi,

    The function that handles comment form it’s the next one

    COPY CODE
    
    if ( ! function_exists( 'kleo_comment_form' ) ) :
    	/**
    	 * Outputs a complete commenting form for use within a template.
    	 * Most strings and form fields may be controlled through the $args array passed
    	 * into the function, while you may also choose to use the comment_form_default_fields
    	 * filter to modify the array of default fields if you'd just like to add a new
    	 * one or remove a single field. All fields are also individually passed through
    	 * a filter of the form comment_form_field_$name where $name is the key used
    	 * in the array of fields.
    	 *
    	 * @param array $args Options for strings, fields etc in the form
    	 * @param mixed $post_id Post ID to generate the form for, uses the current post if null
    	 *
    	 * @return void
    	 */
    	function kleo_comment_form( $args = array(), $post_id = null ) {
    		global $id;
    
    		$user          = wp_get_current_user();
    		$user_identity = $user->exists() ? $user->display_name : '';
    
    		if ( null === $post_id ) {
    			$post_id = $id;
    		} else {
    			$id = $post_id;
    		}
    
    		if ( comments_open( $post_id ) ) :
    			?>
    			<div id="respond-wrap">
    				<?php
    				$commenter = wp_get_current_commenter();
    				$req       = get_option( 'require_name_email' );
    				$aria_req  = ( $req ? " aria-required='true'" : '' );
    				$fields    = array(
    					'author' => '<div class="row"><p class="comment-form-author col-sm-4"><label for="author">' . __( 'Name', 'kleo_framework' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    					'email'  => '<p class="comment-form-email col-sm-4"><label for="email">' . __( 'Email', 'kleo_framework' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    					'url'    => '<p class="comment-form-url col-sm-4"><label for="url">' . __( 'Website', 'kleo_framework' ) . '</label><input id="url" name="url" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p></div>',
    				);
    
    				if ( function_exists( 'bp_is_active' ) ) {
    					$profile_link = bp_get_loggedin_user_link();
    				} else {
    					$profile_link = admin_url( 'profile.php' );
    				}
    
    				$comments_args = array(
    					'fields'            => apply_filters( 'comment_form_default_fields', $fields ),
    					'logged_in_as'      => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'kleo_framework' ), $profile_link, $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink() ) ) ) . '</p>',
    					'title_reply'       => __( 'Leave a reply', 'kleo_framework' ),
    					'title_reply_to'    => __( 'Leave a reply to %s', 'kleo_framework' ),
    					'cancel_reply_link' => __( 'Click here to cancel the reply', 'kleo_framework' ),
    					'label_submit'      => __( 'Post comment', 'kleo_framework' ),
    					'comment_field'     => '<p class="comment-form-comment"><label for="comment">' . __( 'Comment', 'kleo_framework' ) . '</label><textarea class="form-control" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
    					'must_log_in'       => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'kleo_framework' ), wp_login_url( apply_filters( 'the_permalink', get_permalink() ) ) ) . '</p>',
    				);
    
    				comment_form( $comments_args );
    				?>
    			</div>
    
    			<?php
    		endif;
    
    	}
    endif;
    
    

    Paste it in child theme ( wp-content/themes/kleo-child/functions.php ) and change what you need for comment form, in your case the label can be changed from here ( see next screenshot )

    Best regards
    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?