显示在URL中的php ID自定义字段
将自定义字段代码粘贴到Woo commerce模板中,以显示自定义字段链接 使用的代码是:显示在URL中的php ID自定义字段,php,Php,将自定义字段代码粘贴到Woo commerce模板中,以显示自定义字段链接 使用的代码是: <a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a> 但在前端,它将产品ID添加到url中 结果是这样的: <a href="462https://www.example.com/wp-content/uploads/2019/02/2c1ff8dc9046ed92d5e
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>
但在前端,它将产品ID添加到url中
结果是这样的:
<a href="462https://www.example.com/wp-content/uploads/2019/02/2c1ff8dc9046ed92d5e254770412c898.pdf">Download Datasheet</a>
有什么想法吗
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>
The_ID()
的目的是显示post ID,这意味着它将回显它
您需要在这里获取\u ID()
,它只返回ID,而不直接输出它
The_ID()
的目的是显示post ID,这意味着它将回显它
您需要
在此处获取\u ID()
,它只返回ID,不直接输出。谢谢。这就是我错过的!非常感谢。这就是我错过的!
<a href="<?php the_field('datasheet',the_ID()); ?>" >Download File</a>