WordPress.org

Support

Support » How-To and Troubleshooting » add_shortcode question, arrays

add_shortcode question, arrays

  • I am trying to make it as simple for a client to add a shortcode to their text area in the admin and it will produce a Paypal button with options (didn’t see any plugins that would help and are simple). I have

    function paypal_func( $atts ) {
    	echo '<pre>';print_r($atts);echo '</pre>';
    }
    add_shortcode( 'pp', 'paypal_func' );

    and

    [pp button="XXXXBUTTONCODEXXXX" option="Sizes: Small, Medium, Large, Extra Large, XXL" option="Type: Male, Female"]

    the result is:

    Array
    (
        [button] => XXXXBUTTONCODEXXXX
        [option] => Type: Male, Female
    )

    I was hoping that it would result in the option as an array instead of overriding it with the 2nd one. Is there anyway to pull the data and have it result in an array so it would be:

    Array
    (
        [button] => XXXXBUTTONCODEXXXX
        [option] => Array
            (
                [0] => Sizes: Small, Medium, Large, Extra Large, XXL
                [1] => Type: Male, Female
            )
    
    )

    I doubt there is but was hopeful maybe someone came across this problem before.
    thanks.

  • The topic ‘add_shortcode question, arrays’ is closed to new replies.
Skip to toolbar