过滤” the_content”,但带有高级自定义字段

我正在使用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');

但是, 后者不起作用。它只是从页面中删除该字段。有谁知道如何正确使用这些过滤器?


#1


尝试这个: –

function same_youtube_options_controls_acf($value, $post_id, $field )
{
    // run the_content filter on all textarea values
    $value = apply_filters('the_content', $value);
    return $value;
}
add_filter('acf/load_value/name=iframe_url', 'same_youtube_options_controls_acf', 10, 3);

该钩子将使用the_content过滤器替换你的自定义字段值。

来源:

https://www.srcmini02.com/67251.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_36937.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?