wordpress-bootstrap icon indicating copy to clipboard operation
wordpress-bootstrap copied to clipboard

new picture galleries won't show up after updating to WP 3.5.1

Open fheinle opened this issue 11 years ago • 5 comments

I'm running wp 3.5.1 with wp-bootstrap aa52837703109126d2a456b0ce8abe7d75476589 from git.

When I create new image galleries, they won't show up on the page, as in no markup at all. The rest of the post works fine. Galleries I've created before work fine. I tried switching to original wp-bootstrap from my child theme, where I encounter the same issue. Switching to twentyeleven works fine.

When I check post contents using phpmyadmin, both working and non working galleries have the correct gallery shortcode

fheinle avatar Feb 07 '13 09:02 fheinle

Update, I found out the problem lies in the way wordpress-bootstrap retrieves pictures. You can add pictures that you upload as an attachment to your current post, but you can't add pictures you added to another post or no post at all, because post_parent is matched against the current post ID in the gallery shortcode

fheinle avatar Feb 07 '13 18:02 fheinle

A possible fix would be

function gallery_shortcode_tbs($attr) {
    global $post, $wp_locale;
    $output = "";

    $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 

    // 3.5 Gallery Fix
    if ( !empty( $attr['ids']) ) {
        // 'ids' is explicitly ordered, unless you specify otherwise.
        if ( empty( $attr['orderby'] ) )
            $args['orderby'] = 'post__in';
        $args['include'] = $attr['ids'];
        // these may not not have current post set as parent
        unset($args['post_parent']);
    }

    $attachments = get_posts($args);

...

jsmeltzer avatar Feb 22 '13 00:02 jsmeltzer

I had this problem too. Thanks for the fix.

ortzinator avatar May 24 '13 04:05 ortzinator

Great fix!! Thanks =)

McGun avatar Jul 11 '13 08:07 McGun

Same problem here. I can't fix it! Please help :)

Grdbb avatar Jul 13 '14 18:07 Grdbb