WordPress.org

Forums

[resolved] Shortcode with unknown number of imputs? (2 posts)

  1. drazon
    Member
    Posted 1 year ago #

    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?

  2. drazon
    Member
    Posted 1 year ago #

    For anyone that might looking for something similar this is solved here http://stackoverflow.com/questions/20768158/style-input-text-through-wordpress-shortcode

Topic Closed

This topic has been closed to new replies.

About this Topic