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.

So with my blog i have a photo attachment page but it only shows to photo's at a time, and those two photo's are used as the navigation and i hate that.

I want the attachment page to show all the photo's that goes along with the rest of that set.

Here is the current code

        <div id="nav-images" class="navigation clearfix">
            <div class="nav-next"><?php next_image_link() ?></div>
            <div class="nav-previous"><?php previous_image_link() ?></div>

How do i change that to show all the post attachments?

share|improve this question
add comment

2 Answers

Your code and description seem to refer to the previous/next attachment navigation. That code is intended to display previous/next attachment navigation, and that's exactly what it's doing.

If you want to display all attachments:

  1. Within the Post Content, use the [gallery] shortcode
  2. Programmatically, in the template file, use e.g. get_posts(), combined with e.g. wp_get_attachment_image():

    <?php
    global $post;
    $attachment_images = get_posts(
        'post_type' => 'attachment',
        'post_parent' => $post->post_parent,
        'post_mime_type' => 'image'
    );
    // Output images
    ?>
    <ul>
    <?php
    foreach ( $attachment_images as $attachment_image ) {
        // Output images here. Note that get_posts()
        // returns an array of OBJECTS, so the ID
        // would be $attachment_image->ID
        echo '<li>' . wp_get_attachment_image( $attachment_image->ID, 'thumbnail' ) . '</li>';
    }
    ?>
    </ul>
    
share|improve this answer
    
Hi, That post does code does not work, is there another one –  Terrell Anderson Feb 27 '12 at 20:27
    
You've not provided nearly enough information for me to answer your question any more accurately. I don't know what exactly you tried, where you put the code, or what the output was. –  Chip Bennett Feb 28 '12 at 1:53
add comment

Hi Chip, Unfortunately that didn't work, but I finally found it after hours and hours of searching.

First you have to add the below code to the functions.php file

function show_all_thumbs() {
    global $post;
    $post = get_post($post);
    /* image code */
    $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent='.$post->post_parent);
    if($images){
        foreach( $images as $imageID => $imagePost ){
            unset($the_b_img);
            $the_b_img = wp_get_attachment_image($imageID, 'thumbnail', false);
            $thumblist .= '<a href="'.get_attachment_link($imageID).'">'.$the_b_img.'</a>';
        }
    }
    return $thumblist;
}

and then add the below code to where you want the thumbnails to show.

<?php echo show_all_thumbs();?>

Sorry I don't know how to put the whole code in the box so i had to jam toegether every line :(

share|improve this answer
3  
I'm glad you found a working solution, but you're doing almost exactly what I suggested. :) –  Chip Bennett Feb 28 '12 at 1:52
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.