Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Scribu's Posts 2 Posts plugin to connect posts with small galleries attached to an album post type. Everything works great, except that I cannot figure out how to merge the attachments to display together.

Right now I am using the code below to display each gallery one below another.

$images = get_children( array( 
    'post_parent' => $post->ID,
    'post_type' => 'attachment',
    'post_mime_type' => 'image', 
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'numberposts' => 999 ) );

if ( $images ) {
    $total_images = count( $images );
    $image = array_shift( $images );
    $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail', $default_attr );
}

if ($images)
    echo do_shortcode('[gallery size="small" columns="5"]');

Is it possible to grab all of the post attachments connect to an album and combine before this script is run?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You will just have to call get_children() for each gallery:

$images = array();

foreach ( $gallery_posts as $gallery ) {
  $images = array_merge( $images, get_children(
    'post_parent' => $gallery->ID,
    ...
  ) );
}
share|improve this answer
    
Awesome thanks @Scribu! –  mattrepublic Oct 19 '11 at 11:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.