1

Here is my code:
when i use two shortcodes at same page only upper short code working.. Second is not working.
Example:-
if i use these shortcodes [swt_mm post_id=111] [swt_mm post_id=112] then only [swt_mm post_id=111] working not `[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";

  }



}

Please help me if there are any mistakes in this code?

1

I simply replaced
require_once dirname( __FILE__ ) . '/swt_mm_single_box.php';
with

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

and now its worked for me.
check Here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.