Site logo

Archived topic

No formatting possible with ACF WYSIWYG field

9 replies · Started by Björn on November 25, 2022

Viewing posts 1–10 of 10

Hi.

I am using Advanced Custom Fields to display Customer Feedback in a Custom Post Type through a WYSIWYG editor. Unfortunately all paragraphs are merged and no formatting is displayed on the front end.

My Custom Post Type has a custom layout through an element. In the element I am trying to display the respective customer feedback via ACF.

Thanks in advance!

Hi there,

are you using GenerateBlocks Pro ? As that has ACF Support for its Dynamic data

No, only free GenerateBlocks version, unfortunately.

Ok, so instead you would need to create a Shortcode using a PHP Snippet like this:


add_shortcode('customer_feedback', function(){
    ob_start();
    if( get_field('your_custom_field_name') ):
        the_field('your_custom_field_name');
    endif;
    return ob_get_clean();
});

Change the your_custom_field_name to match yours.
Then you can use the shortcode [customer_feedback] in your element content.

As always great support. Works like a charm!

Thank you!

Glad to hear that!

Edit:
Well, Everything went back to normal with the Pro version of GenerateBlocks that I intended to buy anyway.

Sorry for the untimely relaunch of this topic.

Best regards

Hi there,

this is more a consequence of either ACF, WordPress or the TinyMCE editor. So debugging that can be a pain.

In ACF the_field function has 2 additional params:

https://www.advancedcustomfields.com/resources/the_field/

Including the $format which says whether or not to show the HTML format.

Try setting that param to true in the shortcode eg.:


add_shortcode('show_wysiwyg', function(){
    ob_start();
    if( get_field('your_field') ):
        the_field('your_field', false, true );
    endif;
    return ob_get_clean();
});

If that doesn't work then do you have the TinyMCE plugin installed as that may be interfering with what it returns?

Glad to hear that it is working !!

This archived topic is closed to new replies.