Support

Account

Home Forums Backend Issues (wp-admin) Error reading Shortcodes in wysiwyg editor

Solved

Error reading Shortcodes in wysiwyg editor

  • Hi

    I have the Advanced Custom Fields Installed on a website. We have a few fields for each page: Header text (editable using the WordPress editor), header image, and a more info and testimonials page: the last 2 are edited using the WYSIWYG editor form ACF

    I have been asked to add a gallery image which is installed on our site. However, when I type in the shortcode [matrix 2 /], the editor just display the shortcode in text.

    It works ok on the WordPress editor, but we need it further down the page. Is there a workaround so I can enable the shortcode to function correctly in the WYSIWYG editor?

    Please could anyone advise? I have some knowledge of PHP and MySQL and can follow step by step instructions.

    Many thanks in advance.

  • I tried the above PHP – no joy.

  • This worked for me.

    Put this in your functions file:

    <?php 
    function example_sc( $atts ){
    ob_start();
    get_template_part('template','part');
    return ob_get_clean();
    }
    add_shortcode( 'example', 'example_sc' );
    ?>

    Put this in your template file:

    <?php
    if(get_sub_field('wysiwig')):
    $wysiwig = do_shortcode(get_sub_field('wysiwig',false, false));
    else:
    $wysiwig = '';
    endif;
    ?>
    
    <?php echo $wysiwig; ?>
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Error reading Shortcodes in wysiwyg editor’ is closed to new replies.