/* Add review title field on comment form*/ function add_review_title_field_on_comment_form() { echo '<p class="comment-form-title uk-margin-top"><label for="title">' . __( 'Review title', 'text-domain' ) . '</label><input class="uk-input uk-width-large uk-display-block" type="text" name="title" id="title"/></p>'; } add_action( 'comment_form_logged_in_after', 'add_review_title_field_on_comment_form' ); add_action( 'comment_form_after_fields', 'add_review_title_field_on_comment_form' ); /* add save comment to database*/ add_action( 'comment_post', 'save_comment_review_title_field' ); function save_comment_review_title_field( $comment_id ){ if( isset( $_POST['title'] ) ) update_comment_meta( $comment_id, 'title', esc_attr( $_POST['title'] ) ); } function get_review_title( $id ) { $val = get_comment_meta( $id, "title", true ); $title = $val ? '<strong class="review-title">' . $val . '</strong>' : ''; return $title; }