WordPress custom content area with wp editor?


Craig

Using my Wordpress theme features file, I created a custom meta text area (see screenshot below).

When editing a page, the custom element text area is displayed.

enter image description here

Both saving and changing the text work fine, but if I change a specific part of the paragraph text to heading2 and click save, it reverts the heading2 to the paragraph.

After my function update the meta box looks like this:

if( isset( $_POST['my_meta_box_text_challengetbl'] ) )
    update_post_meta( $post_id, 'my_meta_box_text_challengetbl', wp_kses( $_POST['my_meta_box_text_challengetbl'], $allowed ) );
}

The php code for $allowed looks like this:

$allowed = array( 
    'a' => array( // on allow a tags
        'href' => array() // and those anchords can only have href attribute
    )
);
Simon Pollard

please update...

$allowed = array( 
    'a' => array( // on allow a tags
        'href' => array() // and those anchords can only have href attribute
    ),
    'h2' => array()
);

Note that this will allow the use of H2, note: you can also allow any other html tags here. Check out https://codex.wordpress.org/Function_Reference/wp_kses for more information.

Related


WordPress custom content area with wp editor?

Craig Using my Wordpress theme features file, I created a custom meta text area (see screenshot below). When editing a page, the custom element text area is displayed. Both saving and changing the text work fine, but if I change a specific part of the paragrap

WordPress custom content area with wp editor?

Craig Using my Wordpress theme features file, I created a custom meta text area (see screenshot below). When editing a page, the custom element text area is displayed. Both saving and changing the text work fine, but if I change a specific part of the paragrap

WordPress custom content area with wp editor?

Craig Using my Wordpress theme features file, I created a custom meta text area (see screenshot below). When editing a page, the custom element text area is displayed. Both saving and changing the text work fine, but if I change a specific part of the paragrap

WordPress custom content area with wp editor?

Craig Using my Wordpress theme features file, I created a custom meta text area (see screenshot below). When editing a page, the custom element text area is displayed. Both saving and changing the text work fine, but if I change a specific part of the paragrap

WordPress custom content area with wp editor?

Craig Using my Wordpress theme features file, I created a custom meta text area (see screenshot below). When editing a page, the custom element text area is displayed. Both saving and changing the text work fine, but if I change a specific part of the paragrap

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

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

Wordpress on IIS with shared wp content

Ita I've been trying to install Wordpress on IIS, and with a standard install and handler mapping for php-cgi, everything works fine. Since I have a public server (A) and a private shared server (B), I need to do a WP install on server A with a shared database

Wordpress on IIS with shared wp content

Ita I've been trying to install Wordpress on IIS, and with a standard install and handler mapping for php-cgi, everything works fine. Since I have a public server (A) and a private shared server (B), I need to do a WP install on server A with a shared database

Gutenberg editor content in JavaScript (WordPress)

Shramee In the TMCE era, we can easily get editor content editor.getContent(). However, in the new Gutenberg editor, I can't find a way to do this. I need all editor content to be HTML (the way to save it in the database). I found wp.block.serialize()an approa

Gutenberg editor content in JavaScript (WordPress)

Shramee In the TMCE era, we can easily get editor content editor.getContent(). However, in the new Gutenberg editor, I can't find a way to do this. I need all editor content to be HTML (the way to save it in the database). I found wp.block.serialize()an approa

Gutenberg editor content in JavaScript (WordPress)

Shramee In the TMCE era, we can easily get editor content editor.getContent(). However, in the new Gutenberg editor, I can't find a way to do this. I need all editor content to be HTML (the way to save it in the database). I found wp.block.serialize()an approa

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 Shortcode not working in WP page text editor

slightest I'm using the wordpress profilebuilder plugin... When I place the shortcode in the wordpress content area "[wppb-register]" it doesn't contain the code. It only shows shortcode text. Can anyone help me with the problem..i really appreciate it. Sadly

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

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'), '

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

Implement wp-editor in wordpress page

username I created a new plugin. After installing the plugin, a new link will appear under the settings bar in the wordpress dashboard, exam description settings. It has a text field for the exam name and a text area for the exam description. When I give the c

Implement wp-editor in wordpress page

username I created a new plugin. After installing the plugin, a new link will appear under the settings bar in the wordpress dashboard, exam description settings. It has a text field for the exam name and a text area for the exam description. When I give the c

Wordpress Shortcode not working in WP page text editor

slightest I'm using the wordpress profilebuilder plugin... When I place the shortcode in the wordpress content area "[wppb-register]" it doesn't contain the code. It only shows shortcode text. Can anyone help me with the problem..i really appreciate it. Sadly

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'), '