我是PHP新手,我想不出一件简单的事情:
我需要输出到Woordpress上的“高级自定义字段”作为超链接。下面是我正在使用的代码,但我不知道如何正确地将the_field('my-custom-link')变成超链接。它目前正在显示输出,但它并没有像我想要的那样显示为一个包装链接。
printf( '<div class="pdf-cover"><a href="' . the_field('my-custom-link') .'" title="%s">%s</a></div>', the_title_attribute( 'echo=0' ), $img );提前行动!
发布于 2014-10-15 11:39:50
我不知道在Wordpress上有什么函数the_field,所以这意味着你使用的是插件。
但是,大多数与wordpress和wp相关的函数都有回显版本(在本例中是the_field)和返回版本(应该是get_the_field或get_field)。
所以,请试试
printf( '<div class="pdf-cover"><a href="' . get_the_field('my-custom-link') .'" title="%s">%s</a></div>', the_title_attribute( 'echo=0' ), $img );或
printf( '<div class="pdf-cover"><a href="' . get_field('my-custom-link') .'" title="%s">%s</a></div>', the_title_attribute( 'echo=0' ), $img );https://stackoverflow.com/questions/26381501
复制相似问题