[英]php if meta shortcode empty dont show, if got text echo text
如果我的meta框简码中未显示任何内容,我将不显示任何内容:
<?php echo stripslashes(do_shortcode(get_post_meta($post->ID, '_'.$dirname.'_matchquote', true))); ?>
元框简码的编码如下:
'_'.$dirname.'_matchquote' => array(
'name' => '_'.$dirname.'_matchquote',
'title' => __('Match Quote', 'gp_lang'),
'desc' => __('', 'gp_lang'),
'std' => '',
"type" => "textarea"
),
因此,如果该特定框内没有任何内容,我将如何不回声?
目前尚不清楚“那个特定的盒子”是什么,但我认为这是您要的:
$text = stripslashes(do_shortcode(get_post_meta($post->ID, '_'.$dirname.'_matchquote', true)));
if (!empty($text)) {
echo $text;
}
我不明白为什么你正在运行stripslashes
在处理简码。 如果有的话,我认为它应该在该字符串发送到do_shortcode
之前在get_post_meta
的输出上运行。
$text = do_shortcode(stripslashes(get_post_meta($post->ID, '_'.$dirname.'_matchquote', true)));
if (!empty($text)) {
echo $text;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.