OK, I finally made it following this crystal clear tut’: http://ivetetecedor.com/how-to-use-a-drop-down-menu-for-wordpress-custom-fields
Consequently, my functions.php became:
add_action( 'comment_form_logged_in_after', 'additional_fields' ); add_action( 'comment_form_after_fields', 'additional_fields' );
function additional_fields () { echo ''. '' . __( 'Titre (Je peux...)' ) . ''. '
';
echo 'Cette solution est particulièrement utile... Dans tous les cas Sans argent Sans le temps Sans la santé ';
}
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 ); if ( ( isset( $_POST['category'] ) ) && ( $_POST['category'] != '') ) $category = wp_filter_nohtml_kses($_POST['category']); add_comment_meta( $comment_id, 'category', $category );
}
I hope it’ll help
(@tche111)
8 years, 8 months ago
Hi,
I have added a title and a ‘category’ field to my comment form but now I d like to change the category field in a dropdown list. How should I adapt the following code?
Would anybody have an idea on how to change it?
Many thanks in advance for your help!!!
Hopefully,
Thierry