Twenty Eleven Gallery page (6 posts)

  1. poivre
    Posted 4 years ago #


    I am using Twenty eleven theme and post format.... When I create a gallery post format, I would like to have all thumbs appear directly on the post.

    The way it is now: the post that contains a gallery shows a thumb with a text saying the number of photo included. Then we have to click on it to get to the page with all the thumbs...

    I tried to play with content-gallery.php but after hours i didn't get the answer...

    Any help ?

    Thank you

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Do not edit the Twenty Eleven theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes.

  3. poivre
    Posted 4 years ago #

    Thank you...

    Do you know what do change then ?

  4. poivre
    Posted 4 years ago #

    Should be simple to have the gallery thumbs display directly on the first post... Any clue someone ?

    Thank you :-)

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    You;d have to replace:

    <?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' );?>
    <figure class="gallery-thumb">
    <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
    </figure><!-- .gallery-thumb -->
    <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyeleven' ),
    'href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
    number_format_i18n( $total_images )
    ); ?></em></p>

    in your child's content-gallery.php file with something like <?php the_content();?>.

  6. poivre
    Posted 4 years ago #

    Thank you :-)

    I also deleted

    <?php else : ?>
    <?php endif; ?>

    In the beginning and the end of this piece of code.. Otherwise it broke the page...


    <?php the_content();?>

    doesn't bring anything... I only have now the title of the gallery post...

    We are getting close...

    Thank you


Topic Closed

This topic has been closed to new replies.

About this Topic