admin管理员组文章数量:1328037
I'd like to access custom ACF field values from custom_preview()
filter?
add_filter( 'preview_post_link', 'custom_preview' );
function custom_preview() {
// how to access ACF field values here ?
}
I'd like to access custom ACF field values from custom_preview()
filter?
add_filter( 'preview_post_link', 'custom_preview' );
function custom_preview() {
// how to access ACF field values here ?
}
Share
Improve this question
asked Jul 22, 2020 at 9:26
haxpanelhaxpanel
15710 bronze badges
1 Answer
Reset to default 1As documented, the preview_post_link
passes the post object as the second parameter. You can use this to get any fields that you might want:
add_filter(
'preview_post_link',
function( $preview_link, $post ) {
$custom_field = get_field( 'custom_field_name', $post );
return $preview_link;
},
10,
2 // MUST be 2 to get the $post parameter.
);
本文标签: filtersAccess ACF fields within custom preview function
版权声明:本文标题:filters - Access ACF fields within custom preview function? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742242328a2438911.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论