How to pass multiple values in shortcode?

You can create your own shortcode which will hold all of that for you hardcoded:

add_shortcode("my_five_forms","my_five_forms_handler");
function my_five_forms_handler($atts,$content =null){
    $con =  "[frm-entry-delete-link id=9 page_id=25 field_key=hsn108]
        [frm-entry-delete-link id=12 page_id=25 field_key=cp7pi]
        [frm-entry-delete-link id=13 page_id=25 field_key=ksa9qv]
        [frm-entry-delete-link id=14 page_id=25 field_key=9zuf6o]
        [frm-entry-delete-link id=15 page_id=25 field_key=w8w7op]";

    return do_shortcode($con);
}

   // and use it like this:
   [my_five_forms]

or create a shortcode that will render all forms dynamicly

add_shortcode("my_n_forms","my_n_forms_handler");
function my_n_forms_handler($atts,$content=null){
    extract( shortcode_atts( array(
        'id_page_key' => '',
    ), $atts ) );
    $con = '';
    foreach((array)$id_page_key as $f){
        $f = split(":",$f);
        $con .=  ' [frm-entry-delete-link id="'.$f[0].'" page_id="'.$f[1].'" field_key="'.$f[2].'"]';
    }

    return do_shortcode($con);
}

//and you use it like this:
   [my_n_forms id_page_key="12:25:hsn108,13:25:cp7pi"]

Leave a Comment