Hi Elliot,
It didn’t work because I still needed that function for the content area, so I needed an additional function.
I found a link on your old forum half an hour ago that solved all my issues
http://old.support.advancedcustomfields.com/discussion/2613/how-to-disable-auto-p-tags-in-wysiwyg-editor
I was getting p tags around images, and shortcodes – causing lots of errors.
Although, it’s not just images, I have paragraph tags around every shortcode as well, so the shortcodes aren’t doing what they need to do. (UI Tabs)
Hi Elliot, sorry I’m a bit hopeless when it comes to this stuff… I tried
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}
but it didn’t work, is the $content
part supposed to be different?
Thanks for your help,
Belinda
Thanks Elliot! My php isn’t too hot though, do I just change ‘the_content’ to ‘acf_the_content’ ?
Cheers,
Belinda
Hi Elliot,
I have the same problems with <p>
tags appearing around images and around short code. If I start with the code in the wordpress visual or text editor it looks perfect (now that I have the following in my functions.php
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
but in the custom fields I cannot seem to shake those extra paragraph tags. I use the html mode to remove them, update and they appear again.
I’m having similar trouble with shortcodes, but those don’t seem to be working in the wordpress editor either. Same problem happens in both places.
If you have any suggestions I’d really appreciate it.
Thanks,
Belinda
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.