Definition:
function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {}
Display next or previous image link that has the same post parent.
Retrieves the current attachment object from the $post global.
Parameters
- bool $prev: Optional. Default is true to display previous link, false for next.
- $size
- $text
Source code
function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { global $post; $post = get_post($post); $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; $k = $prev ? $k - 1 : $k + 1; if ( isset($attachments[$k]) ) echo wp_get_attachment_link($attachments[$k]->ID, $size, true, false, $text); }
387
No comments yet... Be the first to leave a reply!