How to add a category to comments?

Question

I am currently trying to add a category to the comments on my wordpress site. I already added a title to these and tried several ways to add a dropdown (selection) list to the comment form but I am not good in php and I always receive an error msg…

Here is what I am using in functions.php to add the title field:

add_action( 'comment_form_logged_in_after', 'additional_fields' );
add_action( 'comment_form_after_fields', 'additional_fields' );
function additional_fields () {
echo '<p class="comment-form-title">'.
'<label for="title">' . __( 'Titre (Je peux...)' ) . '</label>'.
'<input id="title" name="title" type="text" size="30"  tabindex="5" /></p>';
}

and here is what I use to save the data:

add_action( 'comment_post', 'save_comment_meta_data' ); 
function save_comment_meta_data( $comment_id ) {
if ( ( isset( $_POST['title'] ) ) && ( $_POST['title'] != '') ) 
$title = wp_filter_nohtml_kses($_POST['title']);
add_comment_meta( $comment_id, 'title', $title );
}

Would anybody know how I could adapt these codes to add another meta field as a selection list of, let’s say, 2 possible values? I have well read this topic here Add a drop down list to comment form? but I don’t undertsand the very long answer…

Thanks a billion times in advance for your help… (I ve been stuck on these for days now)
Sincerely,

Thierry

0
, Thierry 8 years 2015-07-27T02:40:40-05:00 0 Answers 65 views 0

Leave an answer

Browse
Browse