0

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 ?

    3 Answers 3

    1

    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"] 
    1
    • 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 ?CommentedFeb 16, 2012 at 9:50
    1

    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.

    3
    • 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 ?CommentedFeb 16, 2012 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.CommentedFeb 16, 2012 at 9:54
    • Yes, i am thinking the same or need to create new function for it. Thanks bro:)CommentedFeb 16, 2012 at 11:46
    0

    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

    1
    • I know it, and i know that why i asked this questionCommentedFeb 16, 2012 at 9:45

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.