WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to display ALL images in gallery with image.php (14 posts)

  1. Ryan Hellyer
    Member
    Posted 6 years ago #

    Hi,
    In the default theme, if you click on an image in a gallery, it takes you to a page generated via image.php. Do any of you know how to display the original gallery in this page?

    thanks :)

  2. Justin Tadlock
    Member
    Posted 6 years ago #

    This should work:

    <?php
    $post_parent = get_post($post->ID, ARRAY_A);
    $parent = $post_parent['post_parent'];
    
    $attachments = get_children("post_parent=$parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC");
    foreach($attachments as $id => $attachment) :
    	echo wp_get_attachment_link($id, 'thumbnail', true);
    endforeach;
    ?>
  3. Ryan Hellyer
    Member
    Posted 6 years ago #

    Thanks greenshady :)

  4. henri
    Member
    Posted 6 years ago #

    Nice code, do you know how we can define the number of thumbnail per page or how to build a pagination with this code because I have more than 1000 images to display in this main gallery!

    Thanks for your help

    henri

  5. henri
    Member
    Posted 6 years ago #

    Anybody know how I spilt the gallery generated by this code (how to make a pagination?)
    Thanks
    henri

  6. deuts
    Member
    Posted 6 years ago #

    The problem now is when someone comments on my image page, the comments do not show up! Can someone help please....

  7. omgitztrey
    Member
    Posted 5 years ago #

    just add

    <?php comments_template(); // Get wp-comments.php template ?>

    to your attachment.php or image.php

  8. l r
    Member
    Posted 5 years ago #

    Hi
    This is a great fix but I want to add image.php to the thumbnails gallery default.
    So the default gallery has a single pic large image view and a gallery of thumbnails.
    Anyone know a quick fix.
    Click on thumbnail and it changes the big image on the same page.
    ( i hope this makes sense)
    Any pointers really appreciated.
    Many thanks

  9. deuts
    Member
    Posted 5 years ago #

    Hi people,

    I tried using a different theme for my gallery in wordpress using the image.php template. What I did was copied the whole template of performancing's photoblog from header, main index, sidebars, comments template and footer into one file and named as image.php. That's when the problem arose about not being able to display the comments in the bottom.

    Any help is appreciated.

  10. henri
    Member
    Posted 5 years ago #

    anyone find a solution for pagination? Thanks

  11. henri
    Member
    Posted 5 years ago #

    @greenshady your code doesn't work with wp 2.7 it only display some images which are not attach to post... Quite strange

  12. henri
    Member
    Posted 5 years ago #

    found a solution for WP 2.7 :

    <?php
    $post_parent = get_post($post->ID, ARRAY_A);
    $parent = $post_parent['post_parent'];
    
    $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
    foreach($attachments as $id => $attachment) :
    	echo wp_get_attachment_link($id, 'thumbnail', true);
    endforeach;
    ?>
  13. dbasulto
    Member
    Posted 5 years ago #

    using the above code crashes with Internal Error. Any idea? It doesn´t seem to have anything wrong on it...

  14. Kirk T
    Member
    Posted 5 years ago #

    Just loaded GreenShady's code for a friend and it works great.

    Using WP 2.7.1

    Check it out here.

Topic Closed

This topic has been closed to new replies.

About this Topic