admin管理员组文章数量:1302318
What is the correct way to display a value in a link using php?
The (Advanced Custom Fields) php works correctly outside of the html.
Book on Expedia <a class="alignright" href="<?php the_field( 'expedia' ); ?>" target="_blank" ><input class="resume_contact_button" type="button" value="<?php the_field( 'low_rate' ); ?>"></a>
What is the correct way to display a value in a link using php?
The (Advanced Custom Fields) php works correctly outside of the html.
Book on Expedia <a class="alignright" href="<?php the_field( 'expedia' ); ?>" target="_blank" ><input class="resume_contact_button" type="button" value="<?php the_field( 'low_rate' ); ?>"></a>
Share
Improve this question
asked May 22, 2014 at 10:11
MuzzaMuzza
251 silver badge7 bronze badges
9
|
Show 4 more comments
1 Answer
Reset to default 1If the function returns a printed value:
<a href="<?php bloginfo('url'); ?>">Link</a>
If not (using the echo statement):
<a href="<?php echo get_stylesheet_directory_uri(); ?>">Link</a>
You can also use print()
as part of a more complex expression where echo cannot.
By the contrary, when you want to use HTML into PHP, I recommend to close PHP and open it again after the HTML code, instead of using echo "<a href='#'></a>";
like this example:
<?php my_function() { ?>
<a href="<?php bloginfo('url'); ?>">Link</a>
<?php } ?>
Your PHP code is ok, but probably the function returns an empty value. Also, close the INPUT tag with />
.
本文标签: advanced custom fieldsDisplay PHP within HTML values
版权声明:本文标题:advanced custom fields - Display PHP within HTML values 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741683172a2392290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
echo
afterphp
tab like<?php echo the_field('...'); ?>
– ksr89 Commented May 22, 2014 at 10:14the_...
functions in ACF output the field already. – TheDeadMedic Commented May 22, 2014 at 10:19<?php echo field( 'low_rate' ); ?>
– Muzza Commented May 22, 2014 at 10:43