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.

I was trying to create a shortcode for a multiple tabs panel. The user can set the number of tabs, the titles and the content for each. It would be something like :

[tabs number='4']

[tab title='First_tab_title']first tab content[/first_tab]
...
...

[/tabs]

Now, i am wondering. Although it can be done like this, i don't like that i have to create separate shortcodes, like tabs and tab. Is there another better way to pass all this information to a single [tabs] shortcode ?

share|improve this question
    
I wouldn't use shortcodes like this. Why don't you make a TinyMCE plugin instead? –  onetrickpony Jul 20 '11 at 21:18
    
i have a tinymce plugin, i'm not gonna do it by hand. But the output of the shortcode must be like this. It has to be a shortcode in this situation. –  SpyrosP Jul 20 '11 at 22:26
add comment

1 Answer

up vote 0 down vote accepted

You might be able to hack a conditional for 1 shortcode but it seems wonky. Typically you use 2 parameters just like you were using raw html.

There is a smart way around this using custom fields ( which I just happened to do recently).

It does not use any shortcodes at all, the logic is simple it has a custom fields called "tab 1, tab 2, tab 3 , etc" , if no data is entered no tab panels shows up, if there is data in the tab field the panels shows up and dynamically adds tabs per field that is filled out.

I just use jquery tools for the tab panel and default WordPress conditionals for the meta fields, get_post_custom_values specifically.

share|improve this answer
add comment

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.