如果自定义字段为空,请帮助 WordPress 隐藏输入
我制作了一个滑块,如果选中复选框,我可以隐藏它。
我什至给了它一个输入,您可以在其中添加文件夹位置,但如果文件夹为空或不正确,我无法使其隐藏,
这是我尝试将其赋予变量的代码
<?php if(is_category(7) || is_page(11) && get_post_meta($post->ID, 'm_slider', true) == 'true' || 11 == $post->post_parent && get_post_meta($post->ID, 'm_slider', true) == 'true') {?>
<div id='slider_bg'>
</div><!-- slider_bg -->
<div id='slider_img'>
<div class="slider" >
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/1.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/2.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/3.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/4.jpg'>
</div>
</div>
<?php } ?>
,如果它为空则不隐藏它工作中我尝试了 if(get_post_meta($post->ID, 'main_folder', true) !== '')
,但这也不起作用,请有人给我提示我错过了什么?
I made a slider what i can hide if is check a check box.
I even gave it an input where you can add the folder locaton, but i cant make it to hide if the folder is empty or its not correct
this is the code
<?php if(is_category(7) || is_page(11) && get_post_meta($post->ID, 'm_slider', true) == 'true' || 11 == $post->post_parent && get_post_meta($post->ID, 'm_slider', true) == 'true') {?>
<div id='slider_bg'>
</div><!-- slider_bg -->
<div id='slider_img'>
<div class="slider" >
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/1.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/2.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/3.jpg'>
<img src='<?php bloginfo('template_url'); ?>/slider/<?php echo get_post_meta($post->ID, 'main_folder', true); ?>/4.jpg'>
</div>
</div>
<?php } ?>
i tryed to give it to a variable and if its empty than hide it not working i tryed wit if(get_post_meta($post->ID, 'main_folder', true) !== '')
and that doesnt work either, could please someone give me a hint what im missin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以尝试:
You could try :