Very related: Add Media has stopped working in the front end since 4.5 update

I want to run the wp_editor() function to load the classic WordPress editor on the Front-End.

I need to do this out of the WordPress theme, so I am loading WordPress manually:


And that allows me to use the wp_editor() function, with some custom settings.

define('WP_DEBUG', true);

$settings = array(
'wpautop' => true,
'media_buttons' => true,
'textarea_name' => 'contenido',
'textarea_rows' => 12,
'tabindex' => '',
'editor_css' => '',
'editor_class' => '',
'teeny' => false,
'dfw' => false,
'tinymce' => true,
'quicktags' => true

wp_editor( '' /* Empty content */, 'contenido' /* ID */, $settings );

I am also logging in the user as follows:

$user_id = $_SESSION['userID'];
$user = get_user_by( 'id', $user_id ); 

if( $user ) {
    $curr_user = new WP_User( $user_id , $user->user_login ); 
    wp_set_auth_cookie( $user_id );
    do_action( 'wp_login', $user->user_login );

I am loading the required scripts and styles in the head section of the DOM. (Do you know if I am missing something, does the order matter?)

wp_enqueue_script( 'underscore' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'wp-util' );

wp_enqueue_script( 'thickbox' );
wp_enqueue_style( 'thickbox' );

wp_enqueue_script( 'editor' );
wp_enqueue_script( 'quicktags' );
wp_enqueue_style( 'buttons' );
wp_enqueue_script( 'wplink' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'wp-fullscreen-stub' );
wp_enqueue_script( 'media-upload' );
wp_enqueue_script( 'wp-embed' );




But the media button is not working (it shows and reacts to the click event but it does not open the modal on click).

Console error says (when clicking the Insert Media button):

TypeError: i is undefined at underscore.min.js

I digged in the source code and i seems to be referencing the data-editor attribute.

But, at least in the DOM, it is correctly defined.

Maybe I am missing an important script in my queue?

  • Is there a reason you're doing this outside of WordPress? Jan 4, 2020 at 15:20
  • @JacobPeattie Thanks for your time. Yes, the reason is because this is part of an additional Admin Panel (not a substitute for WP Admin) which is already created and cannot easily be integrated into the current WordPress theme. A small group of users should be using this simple interface to send posts (without featured images, slugs... just the post itself). Those posts will be programatically saved as pending. Jan 4, 2020 at 15:37

1 Answer 1


You need to use this script https://github.com/anteprimorac/js-wp-editor.

This can be used to add WordPress editor php: wp_editor()

  • Thank you, but this is useful if I want to add the editor to my current theme and using AJAX. I want to do it out of wordpress and without AJAX. Jan 4, 2020 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.