• Hi all, first Merry Christmas :). Second, I have question. I would like to have more than one image (let say 3 images) on the excerpt of gallery post. In twentyten theme I found this piece code that outputs one image

    <?php
    $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' );
    ?>

    (there is more…)
    But how tu output 3 images? Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • Pavan

    (@pavanluthra)

    try to use this…
    'posts_per_page' => 3

    this will show 3 images to post. u can change the number according to ur need.

    Thread Starter ivan2704

    (@ivan2704)

    This solution just shows 3 image in gallery. I want to be able to put 3 images on the excerpt page if you know what I mean

    Pavan

    (@pavanluthra)

    can u explain what exactly are u saying?

    Thread Starter ivan2704

    (@ivan2704)

    Here is image to explain. Now I have like this, and I want to have 3 images instead this one

    Pavan

    (@pavanluthra)

    is it a post ?

    if it is, then do u want three posts like this?

    Thread Starter ivan2704

    (@ivan2704)

    Here, I think this image explains it

    Pavan

    (@pavanluthra)

    ok, i understood what u want…..
    you have to wait for some time bro…….

    Pavan

    (@pavanluthra)

    these are images uploaded in posts or page?

    Thread Starter ivan2704

    (@ivan2704)

    images are in post in gallery

    Pavan

    (@pavanluthra)

    If images are in post then use this code..

    <?php
    $args = array( 'post_type' => 'attachment', 'numberposts' => -1,'post_status' => null,'post_parent' =>$post->ID,'posts_per_page'=>3);
    						 $attachments=get_posts($args);
     if ( $attachments ){
    	?>
        <ul>
    <?php
       foreach ( $attachments as $attachment ){
          $img = wp_get_attachment_image_src($attachment->ID, 'large');?>
    	<li>
    	<img src="<?php echo $img[0]; ?>" alt='' width="598" height="400"/>
    	</li>
    <?php	}?>
        </ul>
    <?php	} ?>

    It will surely print only three images from your attachment..

    after that apply your stylesheet to look like yours

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Gallery post format; more than one image’ is closed to new replies.