
There are a couple of options.
One way to do this is to create an acf/save_post action with a priority of < 10. In this action you can compare the old value in the field get_field('file_field') with the new value submitted $_POST['acf']['field_KEY'] and if they are different then use wp_delete_attachment() to delete the old file. This will only work after a post has been saved. So if someone adds a file and then changes their mind before saving then the file will not be deleted.
A variation of the above (still using an acf/save_post action) would be get all of the attachments for the post being saved https://stackoverflow.com/questions/42917812/how-to-get-all-attachments-for-a-wordpress-post. All files uploaded in an ACF field should be attached to the post. Then look in every field that is for an attachment (file, image, gallery) and get a list of the ones actually being used and delete the ones that are not. The flaw in this method is that you will not be able to detect files or images that are added in the WP editor or a WYSIWYG field and you’d end up deleting these.
Another way that this could be done is to add custom JavaScript to ACF and add an action to the remove button that fires an AJAX request to delete the file. This would be the best solution, but also the hardest to accomplish.
There is another flaw with every method, you will not know if the same file has been used on another post. Deleting the file if it is used somewhere else will cause issues with wherever else it is used.

I am not having any issues with WYSIWYG fields, either in repeaters or out.
Have you tried a different theme?
Are you seeing any JS errors on the page?


The ACF WYSIWYG field works the same as the WP Classic Editor always worked. autop is applied to the content.
You cannot define your <p> tags in the template when using a WYSIWYG field. If you want to do this then I would suggest you use a textarea field.

You cannot do what you are attempting to do. Images added to a WYSIWYG field are not added to an image field.

All of my sites use ACF and WPForms and I am not seeing any issues with WPForms shortcodes in ACF WYSIWYG fields. I would suspect there is another plugin or something in the theme that’s interfering with WPForms operation. Have you tried deactivating other plugins or trying with a different theme?

You could use the Text Editor/WYSIWYG field
OR
You could use 3 fields
Textarea – to create the text
Textfield – to create the link text
URL – to handle the link
The latter would need more coding to combine the fields
I’m having the same issue. In my case, in addition to links in the WYSIWYG fields, ACF Gutenberg blocks are also getting mangled. My guess is that there’s a WC hook that would allow us to change the function from wp_kses to apply_filters( ‘the_content’… Just need to figure out where it lives.

Hmm, nothing wrong with the code.
What is the field type? I assume a WYSIWYG field?
Do you have any CSS overriding the styling?
If you inspect the list with the browser tools, does it output as HTML UL and LI?
You can use JS for this.
Here is how you can add JS:
https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
And there is a JS filter for changing settings of tinymce (wysiwyg editor) before it’s initialized.
https://www.advancedcustomfields.com/resources/javascript-api/#filters-wysiwyg_tinymce_settings
And here is the final code. Just change ‘field_abcd123456’ to whatever is the key of your field.
add_action('acf/input/admin_footer', function(){
?>
<script>
acf.addFilter('wysiwyg_tinymce_settings', function( mceInit, id, field ){
if(field.get('key') !== 'field_abcd123456'){
return mceInit;
}
mceInit.block_formats = 'Paragraph=p;Heading 4=h4';
return mceInit;
});
</script>
<?php
});
Let’s say it’s a video field. Or an image field. Or a Wysiwyg editor. I actually have all of them, but my main concern is how to implement in code that the field might be empty. PHP or JS. I don’t mind.
The screenshot will help.
Thanks for your time.
Up!
I’ve managed to apply IDs to all WYSIWYG fields, but how could intercept a specific field with its key?
this is the code applied:
function my_heading_ids($content) {
$content = preg_replace_callback(“/\<h([4])/”, function ($matches) {
static $num = 1;
$hTag = $matches[4];
return ‘<h4′. $hTag .’ id=”my’ . $num++ . ‘”‘;
}, $content);
return $content;
}
add_filter(‘acf_the_content’, ‘my_heading_ids’);
Thanks

Just out of curiosity, does the shortcode get inserted into the standard WP editor (classic editor) instead of the ACF WYSIWYG?
I don’t really have an answer and this is only guessing. A lot of tools used for inserting content do not work correctly when there are multiple tinyMCE editors on the page and they assume that only that only the default editor exists.
I have run into this issue in the past with some plugins.

see this https://www.advancedcustomfields.com/resources/customize-the-wysiwyg-toolbars/

If you want to use the_content filter you need to use that acf_the_content filter for WYSIWYG fields
add_filter('the_content', 'ja_ul_class');
add_filter('acf_the_content', 'ja_ul_class');

You can enter html into a message field. It’s not a wysiwyg editor but it works. You can compost the content in a wysisyg editor and then paste it in.

This snippet worked for me.
add_filter( 'acf/get_valid_field', 'change_post_content_type');
function change_post_content_type( $field ) {
if($field['type'] == 'wysiwyg') {
$field['tabs'] = 'visual';
$field['toolbar'] = 'basic';
$field['media_upload'] = 0;
}
return $field;
}
Has there been any progress on this? I have a repeater field with a minimum of 2 items and in the repeater a WYSIWYG block, which have default (some Lorem ipsum text) and when I add a block to the Gutenberg editor a completely empty block is shown. If I click the editor and edit the content the preview becomes visible.
The code above does nothing for me (or do I need to change some values to my field names?)
I made a screencast to better illustrate the issue. As you can se when you edit the block it becomes visible
https://www.youtube.com/watch?v=IzM-OMoHbWQ
I am having the same issue. If WYSIWYG field is used in Gutenberg with position set to ‘Side’, WYSIWYG field is editable at first, but if you select any blocks in the page changing the Gutenberg sidebar tab to ‘Block’ instead of ‘Page’ (taking the WYSIWYG field out of view), and then go back to the ‘Page’ sidebar tab, the WYSIWYG Visual tab is not editable and any content in the Visual tab is gone. However the ‘Text’ WYSIWYG tab does contain its content.
I verified not a plugin or theme conflict by using Twenty Twenty One theme with all plugins deactivated except ACF Pro.

Anything you do to tinyMCE should be reflected in the ACf WYSIWYG fields
https://www.hostpapa.com/knowledgebase/how-to-add-custom-styles-to-wordpress-visual-editor/
Hi Guys,
This may be of use to anyone in the thread so thought I would post it up as a solution.
This plugin just allows you to resize the Gutenberg sidebar which makes working with ACF repeater fields, WYSIWYG’s or any other large field a lot easier.
See here: https://wordpress.org/plugins/resizable-editor-sidebar/.

From your description it appears that the shortcodes plugin that you have installed is not returning anything to be shown. This is what happens when you add a shortcode that does not exist. It seems that the plugin you are using is no longer supported, unless I found the wrong one. ACF WYSIWYG fields run shortcodes.
Solution!!! The Advanced Editor Tools (previously TinyMCE Advanced) plugin worked for me. I couldn’t get the p tags to render using ACF wysiwyg. I would save, view page and no p breaks. Read a ton of threads, didn’t want to touch functions.php or anything of that nature, then got lucky and stumbled upon a forum post where some dude mentioned the aforementioned plugin.
Held my breath, installed the plugin (search for “TinyMCE Advanced”), went to the “classic editor” settings tab, scrolled down to advanced options and toggled “Keep paragraph tags in the Classic block and the Classic Editor” and it worked! Literally jumped out of my seat after spending 4 hours digging for a solution.
I hope this helps someone else in the same spot 🙂
I’m trying to do something similar and just got a reply from ACF. Right now there doesn’t seem to be a way to load anything into a Wsyiwyg field using a filter. I’m trying to load an HTML/PHP template I created into one for emails into the Wysiwyg field in WP-admin. If anyone can help us that would be great!

I’m seeing a wysiwyg for the content field.
What are the settings you’re using for acf_form();
I suspect that you have conflict somewhere.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.