0

如果我的元框短代码中没有显示任何内容,我不想显示任何内容:

<?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"
),

那么,如果那个盒子里什么都没有,我怎么会什么都没有呢?

4

1 回答 1

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;
}
于 2013-03-17T16:05:09.167 回答