logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$1
Gallery Next/Previous Links for Current Gallery Only

I have next/previous links in my image.php and attachment templates:
<?php previous_image_link( false, 'Previous Image' ); ?>
<?php next_image_link( false, 'Next Image' ); ?>


When I create a gallery and click on the image, these links bring me to images which I did not insert into the gallery for that specific post.

I am seeking a code which makes the next/previous links only link to the appropriate next/previous image in the gallery used on that specific parent post. I am seeking a code, not a plugin.

siouxfan45 | 02/04/13 at 4:17pm Edit
Tutorial: How to assign prize money


(3) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    02/04/13
    4:36pm
    Navjot Singh says:

    Check this post at Stackexchange. That solution should work for you as well.

  • avatar
    Last edited:
    02/06/13
    2:51pm
    Kiet Luong says:

    Did you try with attachments images of specific post.

    some thing like this:


    <?php
    // code copied from adjacent_image_link() in wp-include/media.php
    $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
    foreach ( $attachments as $k => $attachment )
    if ( $attachment->ID == $post->ID )
    break;

    $next_url = isset($attachments[$k+1]) ? get_permalink($attachments[$k+1]->ID) : get_permalink($attachments[0]->ID);
    ?>

  • avatar
    Last edited:
    02/04/13
    6:56pm
    siouxfan45 says:

    Actually, that question was posted by me and the solution does not work!

This question has expired.





Current status of this question: Community pot



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.