I would like to filter the $content in my shortcode function so that all I get is the shortcode. I am trying to nest one shortcode inside another dynamically.

Here is my code

function add_slider ($atts, $content='') {

    $atts = shortcode_atts(array (
        'align' => 'center',
        'width' => '50%',
        'height' => 'auto'
    ), $atts);


  /*  foreach($videos as $video) :
             $return.='<li><a href="'.get_permalink().'">'.the_title("","",false).'</a></li>';
        endforeach;
  */
  if( has_shortcode( $content, 'video' ) ) {
            $content = do_shortcode($content);
       return '<ul class="bxslider">' . $content . ' </ul>';
}

else {
    return '<ul class="bxslider"> <li> No Videos Found In Slider </li> </ul>';
}
}
add_shortcode('slider','add_slider' );

Read more here: How to filter $content in shortcode function


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: