如果我的元框短代码中没有显示任何内容,我不会显示任何内容:
<?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"
),
那么,如果某个盒子里面什么都没有,我该如何回应呢?
答案 0 :(得分:0)
目前还不清楚“那个特定的盒子”是什么,但我认为这就是你想要的:
$text = stripslashes(do_shortcode(get_post_meta($post->ID, '_'.$dirname.'_matchquote', true)));
if (!empty($text)) {
echo $text;
}
我不明白为什么你在处理过的短代码上运行stripslashes
。如果有的话,我认为它应该在get_post_meta
的输出之前运行,然后才能将该字符串发送到do_shortcode
。
$text = do_shortcode(stripslashes(get_post_meta($post->ID, '_'.$dirname.'_matchquote', true)));
if (!empty($text)) {
echo $text;
}