Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

drazon on "Shortcode with unknown number of imputs?"

$
0
0

Hello I wanted to ask if
[my_shortcode 'car', 'wheel','text3', ... 'textn'] [/my_shortcode] is possible to give an output like this with 'n' number of args.
`<span class="myclass">car</span>
<span class="myclass">wheel</span>
<span class="myclass">text3</span>`
.....
.....
<span class="myclass">textn</span>
So far I have done this:
[my_shortcode]car,wheel,text3,text4,....,textn[/my_shortcode]

add_shortcode('my_shortcode', 'my_shortcode_function' );
function my_shortcode_function($atts, $content ) {
    return '<span class="myclass">'.$content.'</span>';
}

but of course the output is:
<span class="myclass">car,wheel,text3,text4,....,textn</span>

Can you help me?


Viewing all articles
Browse latest Browse all 8245

Trending Articles