Hey,
I’m using a str_replace to change the content, using WordPress’ default ‘the_content’. However, this does not seem to affect anything that has been submitted through ACF.
I have this:
function same_youtube_options($content) {
return str_replace("rel=0&", "rel0&theme=light&autohide=1&showinfo=0&controls=1&", $content);
}
add_filter('the_content', 'same_youtube_options');
Does ACF have anything similar that I can filter through?
ACF has a nice set of filters. You are probably looking for acf/load_field
Hi @tomjhume
The WYSIWYG field uses a filter called acf_the_content
. It is much the same as the_content
Thanks
E
Thanks guys. I’ve conjured up this, which in my mind should work:
function same_youtube_options_controls_acf($content) {
$content = get_sub_field('iframe_url');
return str_replace("rel=0&", "rel0&&autohide=1&showinfo=0&controls=1&", $content);
}
add_filter('acf/load_field/name=iframe_url', 'same_youtube_options_controls_acf');
However, the iframe_url just disappears.
Sorry to be a pain.
Hi @tomjhume
Using get_sub_field
within this load_field filter will not work.
The get_sub_field function MUST be used within a have_rows
while loop.
Perhaps there is more to your question that originally mentioned?
What are you trying to do? What is your data setup?