WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Comma Separated Values in a Shortcode Attribute

[Resolved] Comma Separated Values in a Shortcode Attribute

  • I am trying to pass comma separated values in a shortcode attribute and having a heck of a time getting it to work.

    The shortcode is: [attachment id=”909,908″]

    The code I have so far only pulls the first value:

    function media_library_shortcode($atts) {
    	extract(shortcode_atts(array( 'id' => 1	), $atts));
    	echo '<ul class="attachment_list">';
    	$value = array($id);
    	foreach ($value as $att_id)
    		{
    		echo '<li>' . wp_get_attachment_link($att_id) . '</li>';
    		}
    	echo '</ul>';
    	}
    	add_shortcode('attachment', 'media_library_shortcode');

    Any assistance would be much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Comma Separated Values in a Shortcode Attribute’ is closed to new replies.