I am trying to create a shortcode with an array as input like so

function product_gallery_shortcode($atts) {

extract(shortcode_atts(array(
            'product_id' => '31',
            'prodvid' => false,
            'youtubeids'=>'',//['lbRqMddP2jo','eFAxx817rC0'],
            'thumbnr' =>2
                ), $atts));

I like to loop throught the youtube id’s but i don’t know how to initialize the youtubeids as an array

so it reads

    'youtubeids'=> array('lbRrePOP2jo','eFAxx17rC0'),

regards

4 s
4

Ok found a solution

function product_gallery_shortcode($atts) {
extract(shortcode_atts(array(
            'product_id' => '31',
            'prodvid' => false,
            'youtubeids'=> '',
            'thumbnr' =>2
                ), $atts));
etc

and i had to turn youtubeids into an array again

$youtubeidsnew = array();
$youtubeidsnew = explode(',', $youtubeids);

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *