WP all import 未将数据导入自定义字段

WP all import is not importing data to custom field

我有一个用 ACF 创建的文本输入字段,我想向它导入值:

function add_manual_button() {
    $link = the_field('navod');

    echo '<div class="col-lg-3 col-12 text-center text-lg-left">';
    echo '<a href="' . $link . '" target="_blank" class="btn-manual btn btn-outline-secondary text-uppercase text-decoration-none font-weight-bold" style="border-radius: 20px; padding: 4px 6px; border-width: 2px;">Montážny návod</a>';
    echo '</div>';
}
add_action('woocommerce_after_add_to_cart_form', 'add_manual_button', 30);

这没有按预期工作。网站的 Href 属性 returns 主页 URL。

分配$link时,需要说

get_field('navod')

不是

the_field('navod')

the_field() 将回显字段值,而 get_field() 获取值并允许您分配它。

此外,另一个快速提示,您可能会发现关闭 php 标签并只写标准 html 而不是在不同的行上回显所有内容更容易