Support

Account

Home Forums ACF PRO Content of WYSIWYG fields is not shown anymore

Solved

Content of WYSIWYG fields is not shown anymore

  • One of my projects got used to a strange irreproducible behavior. It started when i’ve changed the field type from an existing field from text area to WYSIWYG. That worked out without any problems (around the time of the last ACF 4.x versions). With the update to ACF 5.x PRO things worked still fine at first. Then one day, I have to admit i haven’t checked the whole site of my local install on every update of ACF 5.x, at some point around 5.1.6 or maybe little earlier, i’ve noticed that WYSIWYG fields weren’t displayed for that particular changed field anymore. But turned out it isn’t only limited to that field but every WYSIWYG field isn’t displayed anymore and shown empty in consequence. But the odd thing is if i change the field type to text area the particular fields content is shown again.

    I am running WordPress 4.1 and the latest ACF Pro (5.1.7.1). In the wp-config.php WP_DEBUG is set to true (but no php errors show up). I have created an acf-json folder in my themes folder (removing the acf-folder from the themes folder hasn’t helped neither).

    If the field type is set to WYSIWYG the following snippet

    <?php $test = get_field( 'pro_description' );
       	echo '<pre>';
                var_dump( $test );
           echo '</pre>'; ?>

    leads to

    string(0) „"

    if the field is changed to text area the var_dump leads to the correct content output. But that behaviour happens only in the front end. If i go to the backend in the according custom post type the content is shown no matter if the field type is set to WYSIWYG or text area. And the MySQL cells contain the content, even at the point when the WYSIWYG field is selected and the front end is showing nothing, the cells still hold the correct values.
    If I create a fresh wordpress install or check it in other existing installation using acf pro that issue isn’t showing up neither. So something must be gone wrong in this particular installation. Has anyone experienced such an odd behaviour yet? And any ideas how i could debug and figure out the cause of the problem? Cuz so far no errors showed up nor any debug helped, nor the debug objects plugin. Am a bit afraid to update the live site of this site and run into the same problem. :/ Best regards r.

  • Hi @rpk

    It sounds like the issue is coming from the format_value filter. This filter is used to allow each field type (and functions.php) to modify the value based on the field.

    This explains why the field value is returned for non WYSIWYG fields.

    Can you confirm that you have no format_value filter code in your functions.php file which could be clearing the $value?

    Next, try adding 2 false parameters to your code like so:
    $test = get_field( 'pro_description', false, false );

    Does this allowed the WYSIWYG field to return it’s value?

  • Hi @Elliot Condon . There isn’t any format_value in my functions.php. But when i’ve added the double false parameters you’ve suggested all missing fields are shown up again! Thanks!
    But one follow up question. WHY do i have to use false, false in that specific case? I never ran into that before in any of my use cases as well as the get_field documentation on your site ( http://www.advancedcustomfields.com/resources/get_field/ ) isn’t documenting nor suggesting its usage. So what do those false, false actually do? Best regards Ralf

  • Hi @rpk

    The docs describe the 2 params under the parameters section.
    The first is for $post_id, and the second is for $format_value

    Thanks
    E

  • Hi Elliot,

    I have simmilar problem. After update WP to 5.1.1 and WooCommerce to 3.5.7 and ACF free to ACF pro, my custom fields had values. On the frontend WYSIWYG fields are cropped (one or few chars), after first save of the product, the content of the custom fields dissapears. New content inserted into CF’s doesn’t save…
    Could you please help me with this case?

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

The topic ‘Content of WYSIWYG fields is not shown anymore’ is closed to new replies.