Custom Fields
Support General WYSWIYG field and Shortcodes

  • Creator
  • #10652
    Resolved tsquez

    Does the WYSWIYG field allow shortcodes? I saw this post:

    but I think I am having a hard time understanding. Just for testing purposes I used the sample code from the WYSWIYG documentation

        'name'    => 'WYSIWYG / Rich Text Editor',
        'id'      => 'field_id',
        'type'    => 'wysiwyg',
        'raw'     => false,
        'options' => array(
            'textarea_rows' => 4,
            'teeny'         => true,

    So how exactly would I use shortcodes with this?

    Thank for all you do and for all the help. It's greatly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
  • #10655

    OK sorry I just read towards the end of the WYSWIYG documentation:

    Note that the helper function doesn’t format the value of this field nor run shortcodes in the content.

    I do have three shortcodes that I created to be run in this area: one to show the title, one to show the date and one to show the author.

    How would I add those three shortcodes to this:

    $value = rwmb_meta( $field_id );
    echo do_shortcode( wpautop( $value ) );

    Thanks in advance.

    Anh Tran

    Hi Thomas,

    The final code in your previous post parses and runs the shortcodes. Just put the shortcodes in the field's content and they will render well.

    Or am I missing anything?


    So all I do is just make sure to add the do_shortcode and it will run any shortcode added there?

    Anh Tran

    Yes, that's right!


    Hi Anh,

    Is there filter which execute 'do_shortcode' for all metabox?
    For example like filters for widgets.
    add_filter('widget_text', 'do_shortcode' );

    Best regards.

    Anh Tran

    Hi yumikom, please try the rwmb_the_value filter:

    add_filter( 'rwmb_get_value', function( $value, $field, $args, $object_id ) {
        if ( 'wysiwyg' === $field['type'] ) {
            $value = do_shortcode( $value );
        return $value;
    }, 10, 4 );
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.