Home Forums Add-ons Repeater Field Repeater + WYWIWYG bug with shortcode


Repeater + WYWIWYG bug with shortcode

  • Hi Elliot,

    This is sort of a continuation of the older topic “Inconsistencies between standard wysiwyg and ACF wysiwyg“.

    I have found a bug when using the Repeater field with a WYSIWYG field. I am using Syntaxhighlighter, via the plugin “Syntaxhighlighter Evolved“. When displaying code from a WYSIWYG inside a repeater using the Syntaxhighlighter shortcode it only puts in a “1” where it should be showing code. I have built a page here: which shows what it looks like when this happens. This is the shortcode creating the syntax-highlighted code:

    [php] function php_function_example(){}[/php]

    I was able to get this functioning correctly by editing /core/fields/wysiwyg.php and adding this line:

    $value = apply_filters('the_content', $value);

    at the start of format_value_for_api.

    This doesn’t seem like a simple shortcode-display issue though because I added a very basic “foobar” shortcode and that works without adding the apply_filters code.

    Please let me know if I can expand on this further.

    Thank you Elliot,

  • Hi @scottnath

    It is not possible for ACF to run the ‘the_content’ filter on it’s WYSIWYG values as it will cause massive issues such as:

    1. A bbPress forum will render twice
    2. A shopping cart will render twice

    I would advise you to not modify the core functionality, but to just run the_content on the value you get back from the API.

    That way, the code is within your theme, not within ACF.

    You could even just use this filter in your functions.php file to always run the_content on all WYSIWYG values:

    add_filter('acf/format_value_for_api/type=wysiwyg', 'format_value_for_api_wysiwyg', 10, 3);
    function format_value_for_api_wysiwyg( $value, $post_id, $field )
    	$value = apply_filters( 'the_content', $value );
    	return $value;
  • Absolutely perfect solution. I had no desire to update core, just didn’t know how to explain the solution I needed :-).

    As always, thanks a million Elliot!


  • Hi Elliot,

    Looks like this solution has stopped working. Is there a new way to do this?


  • I’m also having the same problem with the latest version. Did this ever get resolved?

  • I have this working in the short term by switching the filter to use ‘load_value’ instead of ‘format_value_for_api’.

    Not sure of the side effects of this yet…

  • Hi guys

    Please note that the filter has changed in ACF PRO. Please change format_value_for_api to format_value:

    add_filter('acf/format_value/type=wysiwyg', 'format_value_wysiwyg', 10, 3);
    function format_value_wysiwyg( $value, $post_id, $field ) {
    	$value = apply_filters( 'the_content', $value );
    	return $value;
  • Hi @elliot.
    I have created ajax function, where inside are repeater fields.
    Once of them has wysiwyg and in the content I have youtube video link (in admin area those was converted to iFrame).
    In ajax response videos are as string.
    I have tried to use apply_filters( 'the_content', $tab['content'], true ); but it doesn’t work.
    format_value_wysiwyg (function above) doesn’t work for me.
    Hope you can help me. Thanks

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Repeater + WYWIWYG bug with shortcode’ is closed to new replies.