John Garcia Fernandez
asked 4 years ago

Hello. Congratulations for this awesome plugin.

I need to include the TinyMCE in the comments textarea. Is it possible?


1 Answers
answered 4 years ago

At the moment, our plugin does not support to make TinyMCE in comments Textarea. If you want to have it, you can try to add the following code to the functions.php file.

function dwqa_ask_form_tag_output($output){
      'orderby'    => 'count',
      'order'    => 'DESC',
      'hide_empty' => false,
    $tag_terms=get_terms('dwqa-question_tag', $args ) ;
    $output='<select name="question-tag" id="question-tag" class="postform">';
    $output.='<option value="">Select question Tags</option>';
    foreach($tag_terms as $tag_term)
      $output.='<option value="'.$tag_term->name.'">'.$tag_term->name.'</option>';
  return $output;

add_filter( 'comment_form_field_comment', 'comment_editor' );

function comment_editor() {
  global $post;


  wp_editor( '', 'comment', array(
    'textarea_rows' => 15,
    'teeny' => true,
    'quicktags' => false,
    'media_buttons' => false
  ) );

  $editor = ob_get_contents();


  //make sure comment media is attached to parent post
  $editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );

  return $editor;

// wp_editor doesn't work when clicking reply. Here is the fix.
add_action( 'wp_enqueue_scripts', '__THEME_PREFIX__scripts' );
function __THEME_PREFIX__scripts() {
add_filter( 'comment_reply_link', '__THEME_PREFIX__comment_reply_link' );
function __THEME_PREFIX__comment_reply_link($link) {
    return str_replace( 'onclick=', 'data-onclick=', $link );
add_action( 'wp_head', '__THEME_PREFIX__wp_head' );
function __THEME_PREFIX__wp_head() {
<script type="text/javascript">
      var args = $(this).data('onclick');
      args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
      args = args.split(',');
      tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
      addComment.moveForm.apply( addComment, args );
      tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
<?php } ?>

Then add the following code to the style.css file:

.dwqa-comment-form #submit {
    display: block;

Hope this helps!

replied 4 years ago

Hello Dominic, Thanks for your answer.
I have tried the solution, but unfortunately it does not work.

dominic Staff
replied 4 years ago

You can send me username & password of your site via private answer for further checking.

Powered by DW Question & Answer Pro