This topic created in 3357 days ago, the information mentioned may be changed or developed.
<div class="buy">
<a rel="nofollow" href="<?php if(get_post_custom_values("url")){ $values = get_post_custom_values("url"); echo $values[0];}?>" target="_blank">链接 ></a>
</div>
那个值是 URL
就是当这个值为空的时候,我想隐藏这个 DVI
求高手帮忙看看,万分感谢!!
9 replies • 2017-04-04 07:06:02 +08:00
 |
|
1
Kilerd Apr 3, 2017 via iPhone
display none
|
 |
|
2
qiayue Apr 3, 2017 1
DIV <?php if(get_post_custom_values("url")):?> <?php $values = get_post_custom_values("url"); ?> <div class="buy"> <a rel="nofollow noopener" href="<?php echo $values[0];}?>" target="_blank">链接 ></a> </div> <?php endif;?>
|
 |
|
3
qiayue Apr 3, 2017 1
多说两句,你之前的写法,已经实现了,值为空的时候,链接的 href 没有内容,也就是隐藏了内容,那么同样的原理,你要想隐藏 DIV ,你就把判断的代码放到 DIV 外面就行。
|
 |
|
4
isCyan Apr 3, 2017 via Android
你们真厉害,我第一眼还以为是那个 DVI 接口
|
 |
|
5
ilaipi Apr 3, 2017 via iPhone
应该是习惯性把 div 写成 DVI 啊!代码里没有写错,标题和正文里两个地方都写错
|
 |
|
7
zulwfryk Apr 3, 2017
这么基础的题目也好意思拿上来问?问之前不会搜一下?
竟然还有人回答
|
 |
|
8
cxbig Apr 4, 2017 1
这个写法有点老套。。。 把整个 DIV 放到一个 if 里就好 <?php if( url_is_empty ): ?> <div>...</div> <?php endif ?>
|
 |
|
9
lcnr Apr 4, 2017 via Android
还是头一次在 v2 看到比我还菜的……
|