[英]Use php to hide anchor text on Wordpress custom field
I am a noob at PHP & am trying to create a wordpress template using the Advanced Custom Fields plugin. 我是PHP的菜鸟,我正在尝试使用“高级自定义字段”插件创建wordpress模板。 The template does mostly what I want it to do but I need to hide the anchor text (the text that says BIO) so that it does not show on the page unless there is information entered into the coach_bio_1 field.
该模板基本上可以完成我想要的操作,但是我需要隐藏锚文本(表示BIO的文本),以便除非在coach_bio_1字段中输入了信息,否则它不会显示在页面上。 The field data is wrapped in a div that shows with fancybox when the link is clicked.
单击链接时,字段数据被包装在div中,该div中带有fancybox。 Here is the code, I realize that this is probably a simple fix, thanks for your help
这是代码,我意识到这可能是一个简单的修复,感谢您的帮助
<div class="coach_info">
<div class="coach_pic"><img src="<?php the_field('coach_pic_1'); ?>" /></div>
<div class="coach_content">
<p class="coach_title"><?php the_field('coach_name_1'); ?></p><br />
<p><?php the_field('coach_title_1'); ?></p><br />
<p><?php the_field('coach_email_1'); ?></p>
<a href="#bio_1" class="fancybox">BIO</a>
<div style="display:none;">
<div id="bio_1">
<?php the_field('coach_bio_1'); ?>
</div>
</div>
</div>
</div><!-- coach_info -->
like this: 像这样:
<?php
if ( get_field('coach_bio_1') ) {
?>
<a href="#bio_1" class="fancybox">BIO</a>
<div id="bio_1">
<?php the_field('coach_bio_1'); ?>
</div>
<?php
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.