我正在使用 str_replace 进行更改the_content
,使用 WordPress 的默认 'the_content'。
但是,这似乎不会影响通过高级自定义字段插件提交的任何内容。
我的原始功能,适用于默认的 WordPress 编辑器:
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');
并且,针对高级自定义字段进行了调整:
function same_youtube_options_controls_acf($field) {
$field = get_sub_field('iframe_url');
return str_replace("rel=0&", "rel0&&autohide=1&showinfo=0&controls=1&", $field);
}
add_filter('acf/load_field/name=iframe_url', 'same_youtube_options_controls_acf');
但是,后者不起作用。它只是从页面中删除该字段。有人知道如何正确使用这些过滤器吗?