Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

All

I am using formidable plugin and on one page i need to use 5 shortcodes.

[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]

Is that possible to pass this all in single short code ?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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"]
share|improve this answer
    
Thanks, Why i want to do this because this all short code generate user name list after then i want to short them alphabetically. Is there any way i can do this ? –  Ajay Patel Feb 16 '12 at 9:50

In short no. Shortcodes in general have keys they expect to deal with and a set way of processing them.

For instance:

[frm-entry-delete-link id=9 page_id=25 field_key=hsn108 id2=12 page_id2=25 field_key2=cp7pi]

won't work as the shortcode will not recognise the keys id2,page_id2,field_key2. Nor can you do it using this method:

[frm-entry-delete-link id=9 page_id=25 field_key=hsn108 id=12 page_id=25 field_key=cp7pi]

As the later values replace the first.

You could get round this by creating a custom shortcode which just runs through and do_shortcodes each one, but really listing 5 short-codes is fine - and a custom shortcode would be an unnecessary waste, and perhaps more confusing than listing them individually.

share|improve this answer
    
Thanks Stephen Harris, but it will not work for me.Why i want to do this because this all short code generate user name list after then i want to short them alphabetically. Is there any way i can do this ? –  Ajay Patel Feb 16 '12 at 9:49
1  
Only if the shortcodes provide that option I'm afraid :S. The only other way would be to dig around the plug-in code and write a shortcode to do it for you. You could always contact the plug-in author a request it as a feature. –  Stephen Harris Feb 16 '12 at 9:54
    
Yes, i am thinking the same or need to create new function for it. Thanks bro:) –  Ajay Patel Feb 16 '12 at 11:46

Have a read of the shortcode API which explains everything you need to know about using and developing shortcodes.

http://codex.wordpress.org/Shortcode_API

share|improve this answer
    
I know it, and i know that why i asked this question –  Ajay Patel Feb 16 '12 at 9:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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