Using WordPress’ WYSIWYG for comments

Give this a shot:

<?php
/* Add WYSISYG editor to comment form. */
add_filter( 'comment_form_field_comment', 'wpse_64243_comment_editor' );

function wpse_64243_comment_editor( $field ) {

    if (!is_single()) return $field; //only on single post pages.
    global $post;

    ob_start();

    wp_editor( '', 'comment', array(
        'textarea_rows' => 15
    ) );

    $editor = ob_get_contents();

    ob_end_clean();

    //make sure comment media is attached to parent post

    $editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );

    return $editor;

}

Leave a Comment