我需要将我的 ACF 字段添加到自定义函数中。我试过了,但有语法错误。
add_action( 'flatsome_custom_single_product_1', function () {
echo <?php the_field('designer'); ?>;
} );
答案 0 :(得分:0)
当您在实际帖子循环之外调用 the_field('designer') 时,您还需要传递帖子 ID。 这是Ref。
对于您的情况,您可以使用如下代码来实现这一点
add_action( 'flatsome_custom_single_product_1', function () {
global $post;
echo get_field('designer', $post->ID);
} );