一页中的两个简码在wordpress中不起作用



这是我的代码:
当我在同一页面上使用两个短代码时,只有上面的短代码有效。第二个是不起作用。
例:
如果我[swt_mm post_id=111] [swt_mm post_id=112]使用这些短代码,那么只有[swt_mm post_id=111]在工作,而不是[swt_mm post_id=112]

<?php
add_shortcode( 'swt_mm', 'swt_mm_shortcode' );
function swt_crypo_shortcode($atts = array(), $content = null, $tag ){
   shortcode_atts(array(
                        'post_type' => 'swt_mm_type',
                        'post_id'
                        ), $atts);
 /*echo $atts['post_id'];*/
  $chk=get_post_meta($atts['post_id'], 'swt_mm_type', true);
  if($chk=='table'){
    require_once dirname( __FILE__ ) . '/swt_mm_table.php';
  }else if($chk=='tooltip'){
    require_once dirname( __FILE__ ) . '/swt_mm_tooltip.php';
  }else if($chk=='box'){
    require_once dirname( __FILE__ ) . '/swt_mm_box.php';
  }else if($chk=='single-box'){
    require_once dirname( __FILE__ ) . '/swt_mm_single_box.php';
  }else{
    echo "Shortcode ID is wrong";
  }
}

如果此代码中有任何错误,请帮助我?

我只是简单地替换了

require_once dirname( __FILE__ ) . '/swt_mm_single_box.php';

define('__ROOT__', dirname(__FILE__)); 
include __ROOT__.'/swt_mm_single_box.php';

现在它对我有用。点击这里

最新更新