Insert shortcode in post editor from javascript (Visual / HTML)

I was pulling my hair out on this one, but I might have figured it out. Try this (with jQuery): if( ! tinyMCE.activeEditor || tinyMCE.activeEditor.isHidden()) { jQuery(‘textarea#content’).val(“[SHORTCODE]test[/SHORTCODE] “); } else { tinyMCE.execCommand(‘mceInsertRawHTML’, false, “[SHORTCODE]test[/SHORTCODE] “); } Basically, you need to set the value of the textarea directly if the editor is hidden.

wp_enqueue_script adds only the first script

You gave each each script the same handle/id of ‘grid’ Try something like this. function banana_scripts() { wp_enqueue_script(‘grid’, get_stylesheet_directory_uri() . ‘/js/jquery.min.js’, null, null); wp_enqueue_script(‘grid2’, get_stylesheet_directory_uri() . ‘/js/main.js’, null, null); } add_action(‘wp_enqueue_scripts’, ‘banana_scripts’);