wordpress how to add wp_editor in array


Said Mohammad Aladdin

I have a small problem with my wordpress code, I need to display a wordpress wp_editor in a page which has an array of values. These values ​​are defined as follows

    $fields[] = array(
        'name' => __('Class', 'my-theme'),
        'desc' => __('', 'my-theme'),
        'id' => 'class'.$n,
        'std' => ( ( isset($class_text[$n]['class']) ) ? $class_text[$n]['class'] : '' ),
        'type' => 'text');

When I define wp_editor like the array above, it doesn't show up where I want it to. Instead, show all editors on top of any content in all pages.

I tried the following set of arrays for the editor:

    $fields[] = array(
        'name' => __('My Content', 'my-theme'),
        'id' => 'sectioncontent'.$n,
        'std' => ( ( isset($class_text[$n]['content']) ) ? $class_text[$n]['content'] : '' ),
        'type' => wp_editor( '', 'sectioncontent'.$n ));

Attaching a picture of my problem:

enter image description here

Touqeer Shafi

reason

By default, wp_editor prints the text area, that's why you can't assign it to any variable or array.

untie

You can use php's output buffering to get the print data in a variable like this:

ob_start(); // Start output buffer

// Print the editor
wp_editor( '', 'sectioncontent'.$n );

// Store the printed data in $editor variable
$editor = ob_get_clean();

// And then you can assign that wp_editor to your array.

$fields[] = array(
        'name' => __('My Content', 'my-theme'),
        'id' => 'sectioncontent'.$n,
        'std' => ( ( isset($class_text[$n]['content']) ) ? $class_text[$n]['content'] : '' ),
        'type' => $editor); // <-- HERE

Related


wordpress how to add wp_editor in array

Said Mohammad Aladdin I have a small problem with my wordpress code, I need to display a wordpress wp_editor in a page which has an array of values. These values are defined as follows $fields[] = array( 'name' => __('Class', 'my-theme'), '

wordpress how to add wp_editor in array

Said Mohammad Aladdin I have a small problem with my wordpress code, I need to display a wordpress wp_editor in a page which has an array of values. These values are defined as follows $fields[] = array( 'name' => __('Class', 'my-theme'), '

wordpress how to add wp_editor in array

Said Mohammad Aladdin I have a small problem with my wordpress code, I need to display a wordpress wp_editor in a page which has an array of values. These values are defined as follows $fields[] = array( 'name' => __('Class', 'my-theme'), '

How to add custom attribute to Wordpress wp_editor text area?

Kapil yadav How to add custom attribute to Wordpress wp_editor textarea field? In the official documentation, there is no way to do this. I need to add a client-side validation attribute (data-bvalidator="required") to a text area generated by WordPress ' wp_e

How to add custom attribute to Wordpress wp_editor text area?

Kapil yadav How to add custom attribute to Wordpress wp_editor textarea field? In the official documentation, there is no way to do this. I need to add a client-side validation attribute (data-bvalidator="required") to a text area generated by WordPress ' wp_e

How to add custom attribute to Wordpress wp_editor text area?

Kapil yadav How to add custom attribute to Wordpress wp_editor textarea field? In the official documentation, there is no way to do this. I need to add a client-side validation attribute (data-bvalidator="required") to a text area generated by WordPress ' wp_e

How to add custom attribute to Wordpress wp_editor text area?

Kapil yadav How to add custom attribute to Wordpress wp_editor textarea field? In the official documentation, there is no way to do this. I need to add a client-side validation attribute (data-bvalidator="required") to a text area generated by WordPress ' wp_e

How to add custom attribute to Wordpress wp_editor text area?

Kapil yadav How to add custom attribute to Wordpress wp_editor textarea field? In the official documentation, there is no way to do this. I need to add a client-side validation attribute (data-bvalidator="required") to a text area generated by WordPress ' wp_e

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

WordPress wp_editor removes html tags - how to stop it?

field Why does wp_editor remove all my html tags? Here is my code: /** * Outputs the content of the meta box. */ function prfx_meta_callback( $post ) { // echo 'This is a meta box'; wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' ); $prfx_stor

wp_editor: How to load wp_editor on demand with jQuery?

username I am trying to load wp_editor on demand using jquery/javascript. I have somehow successfully used the following code, but it is not saving the changed data in the element. tinyMCE.execCommand('mceAddEditor', false, textarea_id); I will be very gratef

Include TinyMCE plugin in Wordpress wp_editor?

Mathias Svensson Carlson Plugins are currently being written for WordPress, including the TinyMCE plugin for WordPress' built-in editor. However, when I print the TinyMCE editor on the custom admin page with: wp_editor( $content, $editor_id, $settings ); The

load wordpress wp_editor dynamically (ajax)

Zac This is an answer/solution rather than a question, still there maybe some bugs, even I tried on my dev env. I recently try to use wp_editor in widget/menu, after some search, I did not find a complete solution as I want. I would share my solution in below

Dynamically load wordpress wp_editor (ajax)

Zach This is an answer/solution, not a question, even if I try to use my development environment, there may still be some bugs. I recently tried to use wp_editor in a widget/menu and after some searching I didn't find the complete solution I was looking for. A

Add default content to wp_editor

Anna Wellington I need to know how to add several paragraphs when viewing wp_editor. I'm using the PHP snippet plugin to display wp_editor on the front end and need to add some explanatory text when the editor loads. Code: wp_editor( $distribution, 'distributi

How to detect changes in wp_editor?

username How to detect in JavaScript if the content wp_editorof tinyMCE instance has changed in WordPress 4.2.2 ? I have tried tinyMCE.editors["content"].isDirty()but the result is always wrong. Yibao if (tinyMCE.activeEditor.isDirty()) alert("You must sav

Replace text area wp_editor() with WordPress TinyMCE

Henry Wright I am trying to replace textarea with wp_editor() My textarea form element looks like this: <textarea name="post_text" id="post_text" rows="3"><?php echo $content; ?></textarea> Then I have: wp_editor( $content, 'post_text' ); The problem I'm hav

Replace text area wp_editor() with WordPress TinyMCE

Henry Wright I am trying to replace textarea with wp_editor() My textarea form element looks like this: <textarea name="post_text" id="post_text" rows="3"><?php echo $content; ?></textarea> Then I have: wp_editor( $content, 'post_text' ); The problem I'm hav

How to add table under post editor in wordpress?

username I need to add a custom form below the post editor in wordpress. I have a custom post type hut here and I can add the hut and its details like title, details, add custom fields by type plugin, feature images, etc. Now I need to create a custom form bel