diff --git a/library/shortcodes.php b/library/shortcodes.php
index 3c3ee287..8083f435 100644
--- a/library/shortcodes.php
+++ b/library/shortcodes.php
@@ -9,28 +9,37 @@
add_shortcode('gallery', 'gallery_shortcode_tbs');
function gallery_shortcode_tbs($attr) {
- global $post, $wp_locale;
-
- $output = "";
-
- $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
- $attachments = get_posts($args);
- if ($attachments) {
- $output = '
';
- foreach ( $attachments as $attachment ) {
- $output .= '- ';
- $att_title = apply_filters( 'the_title' , $attachment->post_title );
- $output .= wp_get_attachment_link( $attachment->ID , 'thumbnail', true );
- $output .= '
';
- }
- $output .= '
';
- }
- return $output;
+ $output = "";
+
+ $ids = explode(",",$array['ids']);
+ $posts=array();
+
+ $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' =>'any', 'post_parent' => $post->ID );
+
+ $attachments = get_posts($args);
+ if ($attachments) {
+ $output = '';
+
+ foreach ( $attachments as $attachment ) {
+ $posts[$attachment->ID]=$attachment;
+ }
+ foreach ( $ids as $id ) {
+ $attachment = $posts[$id];
+
+ $output .= '- ';
+ $att_title = apply_filters( 'the_title' , $attachment->post_title );
+ $output .= wp_get_attachment_link( $attachment->ID , 'thubnail', true );
+ $output .= '
';
+ }
+ $output .= '
';
+ }
+ return $output;
+
+ wp_reset_postdata();
}
-
// Buttons
function buttons( $atts, $content = null ) {
extract( shortcode_atts( array(
@@ -131,4 +140,4 @@ function blockquotes( $atts, $content = null ) {
-?>
\ No newline at end of file
+?>