将“自定义字段”代码粘贴到Woo商务模板中以显示“自定义字段”链接。
使用的代码是:
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>
但是在前端,它将产品ID添加到网址中。
它最终看起来像这样:
<a href="462https://www.fortesdesign.com.au/petefw/wp-content/uploads/2019/02/2c1ff8dc9046ed92d5e254770412c898.pdf">Download Datasheet</a>
有什么想法吗?
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>
答案 0 :(得分:0)
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>
the_ID()
的目的是显示帖子ID,这意味着它会回显它。
您要在这里get_the_ID()
,它仅返回 ID,但不直接输出它。