Custom Fields
Support General Save Wysiwyg content as post_content

  • Creator
  • #5234
    Resolved clientservices

    Is it possible to save a Wysiwyg field's content into the post_content.
    Also if i created a Wysiwyg field, could i and how will i set the default value as post_content. (assuming i already had content in wp default Wysiwyg)

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #5243
    Anh Tran

    Hi, to save wysiwyg field's content into the post_content, you have to do the trick:

    - Setup the post type not to support editor (using this function
    - Set the wysiwyg field the id = content.

    If you do that, you can set the std value as the post content by querying the post content.

    This is the code:

    PS: this question is asked quite frequently, so I created a tutorial for it here with more details:


    I have this set up, and in the WYSIWYG editor for the content field I can set a link on some text, but after saving the post the link is removed. What am I missing?

    You had me add a custom html field to the Field Group with the following:


    the full code for the Field Group is:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
        $meta_boxes[] = array (
            'title' => esc_html__( 'Code Snippet Before', 'text-domain' ),
            'id' => 'code-snippet-before',
            'post_types' => array(
                0 => 'code-snippet',
            'context' => 'after_title',
            'priority' => 'high',
            'fields' => array(
                array (
                    'id' => $prefix . 'content',
                    'name' => esc_html__( 'Reason for snippet', 'text-domain' ),
                    'type' => 'wysiwyg',
                    'desc' => '###Why did I need to use this?
    This field is also used as the Excerpt for the post.###',
                    'class' => 'reason-for-snippet',
                array (
                    'id' => $prefix . 'what-it-does',
                    'name' => esc_html__( 'What It Does', 'text-domain' ),
                    'type' => 'wysiwyg',
                array (
                    'id' => $prefix . 'actual-code-snippet',
                    'name' => esc_html__( 'Actual Code Snippet', 'text-domain' ),
                    'type' => 'wysiwyg',
                    'sanitize_callback' => 'none',
                array (
                    'id' => $prefix . 'before-the-snippet',
                    'type' => 'single_image',
                    'name' => esc_html__( 'Before the snippet', 'text-domain' ),
                array (
                    'id' => $prefix . 'after-the-snippet',
                    'type' => 'single_image',
                    'name' => esc_html__( 'After the snippet', 'text-domain' ),
                array (
                    'id' => $prefix . 'custom_html_sbvmvz193m',
                    'type' => 'custom_html',
                    'std' => '<style>#wp-content-editor-tools{background:none;padding-top:0;}</style>\'',
            'style' => 'seamless',
        return $meta_boxes;
    Long Nguyen


    You need to add the default content for the field wysiwyg and set the value for the 'content' custom field. For your case, the code would be

    Remember change the post to your post type and follow the code in the documentation

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.