{"id":101,"date":"2011-05-08T08:00:28","date_gmt":"2011-05-08T08:00:28","guid":{"rendered":"http:\/\/pixert.com\/blog\/?p=101"},"modified":"2011-08-11T06:03:49","modified_gmt":"2011-08-11T06:03:49","slug":"wordpress-click-an-attachment-image-to-view-next-image-in-order","status":"publish","type":"post","link":"https:\/\/pixert.com\/blog\/wordpress-click-an-attachment-image-to-view-next-image-in-order\/","title":{"rendered":"WordPress: Click an attachment image to view next image in order"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"25\" data-permalink=\"https:\/\/pixert.com\/blog\/how-to-upgrade-wordpress\/wordpresslogo\/\" data-orig-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=498%2C113&amp;ssl=1\" data-orig-size=\"498,113\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"WordPress &#8211; the logo\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=300%2C68&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=498%2C113&amp;ssl=1\" class=\"aligncenter size-medium wp-image-25\" title=\"WordPress - the logo\" src=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=300%2C68\" alt=\"\" width=\"300\" height=\"68\" srcset=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?resize=300%2C68&amp;ssl=1 300w, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?w=498&amp;ssl=1 498w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Add the following to the top of attachment.php<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\n\r\n&lt;?php\r\n\/\/ code copied from adjacent_image_link() in wp-include\/media.php\r\n$attachments = array_values(get_children( array('post_parent' =&gt; $post-&gt;post_parent, 'post_status' =&gt; 'inherit', 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order ID') ));\r\nforeach ( $attachments as $k =&gt; $attachment )\r\n  if ( $attachment-&gt;ID == $post-&gt;ID )\r\n    break;\r\n\r\n$next_url =  isset($attachments&#x5B;$k+1]) ? get_permalink($attachments&#x5B;$k+1]-&gt;ID) : get_permalink($attachments&#x5B;0]-&gt;ID);\r\n?&gt;\r\n\r\n<\/pre>\n<p>Find your attachment image code in attachment.php<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\n\r\n&lt;p class=&quot;attachment&quot;&gt;&lt;a href=&quot;&lt;?php echo $next_url; ?&gt;&quot;&gt;&lt;?php echo wp_get_attachment_image( $post-&gt;ID, $size='fullsize' ); ?&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Add the following to the top of attachment.php &lt;?php \/\/ code copied from adjacent_image_link() in wp-include\/media.php $attachments = array_values(get_children( array(&#8216;post_parent&#8217; =&gt; $post-&gt;post_parent, &#8216;post_status&#8217; =&gt; &#8216;inherit&#8217;, &#8216;post_type&#8217; =&gt; &#8216;attachment&#8217;, &#8216;post_mime_type&#8217; =&gt; &#8216;image&#8217;, &#8216;order&#8217; =&gt; &#8216;ASC&#8217;, &#8216;orderby&#8217; =&gt; &#8216;menu_order ID&#8217;) )); foreach ( $attachments as $k =&gt; $attachment ) if ( $attachment-&gt;ID == $post-&gt;ID ) break; $next_url [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[54,5],"tags":[55,6,7],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-code-snippet","category-wordpress","tag-code-snippet-2","tag-wordpress-2","tag-wp"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1pvi1-1D","jetpack-related-posts":[{"id":418,"url":"https:\/\/pixert.com\/blog\/many-attachment-wordpress-post\/","url_meta":{"origin":101,"position":0},"title":"How many attachment in a WordPress post has?","author":"Pixel Insert \/ Pixert","date":"March 4, 2015","format":false,"excerpt":"There was a case where a client wanted to remove previous and next arrows in attachment images slider. The problem was that she wanted to remove arrows when only one image in WordPress attachment, \u00a0arrows still showing when there're\u00a0more than one images. The solution was to found\u00a0out how many attachment\u2026","rel":"","context":"In &quot;WordPress&quot;","block_context":{"text":"WordPress","link":"https:\/\/pixert.com\/blog\/category\/wordpress\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2015\/02\/wordpressattachmentnum.jpg?fit=1200%2C763&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2015\/02\/wordpressattachmentnum.jpg?fit=1200%2C763&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2015\/02\/wordpressattachmentnum.jpg?fit=1200%2C763&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2015\/02\/wordpressattachmentnum.jpg?fit=1200%2C763&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2015\/02\/wordpressattachmentnum.jpg?fit=1200%2C763&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":314,"url":"https:\/\/pixert.com\/blog\/wordpress-add-title-to-img-tag-using-get-the-image-plugin\/","url_meta":{"origin":101,"position":1},"title":"WordPress: Add Title to IMG tag using Get The Image plugin","author":"Pixel Insert \/ Pixert","date":"October 29, 2013","format":false,"excerpt":"Get The Image plugin from Justin Tadlock is awesome, a script that can grab an image by custom field input, WordPress' featured image, post attachment, or extracting it from the post's content. Recently, someone asked about how to add Title to IMG tag. We know ALT attributes in IMG tag,\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/screenshot-1.jpg?fit=1138%2C742&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/screenshot-1.jpg?fit=1138%2C742&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/screenshot-1.jpg?fit=1138%2C742&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/screenshot-1.jpg?fit=1138%2C742&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/screenshot-1.jpg?fit=1138%2C742&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":231,"url":"https:\/\/pixert.com\/blog\/wordpress-shortcode-in-custom-fields\/","url_meta":{"origin":101,"position":2},"title":"WordPress: Shortcode in Custom Field","author":"Pixel Insert \/ Pixert","date":"June 5, 2012","format":false,"excerpt":"Normally wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [\/shortcode]) you\u2019ll end up displaying the entire text, including the tags. Add the following\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":218,"url":"https:\/\/pixert.com\/blog\/how-to-fix-custom-field-for-thumbnails-wpzoom-featured-category-widget\/","url_meta":{"origin":101,"position":3},"title":"How to fix Custom Field for thumbnails in WPZoom Featured Category widget","author":"Pixel Insert \/ Pixert","date":"April 6, 2012","format":false,"excerpt":"WPZoom Featured Widget is a widget built inside WPZOOM themes to show Featured Category posts The widget display thumbnail images, post titles and post meta datas from selected Featured Category There's a bug in wpzoom-widgets.php where as all widgets code are. The widget cannot display thumbnail images from custom field\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/04\/featuredcat-208x300.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":305,"url":"https:\/\/pixert.com\/blog\/wordpress-conditional-tag-to-check-specific-menu\/","url_meta":{"origin":101,"position":4},"title":"WordPress: Conditional tag to check a specific menu","author":"Pixel Insert \/ Pixert","date":"May 22, 2013","format":false,"excerpt":"Following conditional tag usually use in this filter function, wp_nav_menu_items [php]if( $args->theme_location == 'primary' )[\/php] \u00a0 [php]if( $args->theme_location == 'secondary' )[\/php] \u00a0 [php]if( $args->theme_location == 'primary' )[\/php] For an example, I want to add search box to Primary Menu in WPZOOM theme name Videozoom. Conditional tag above make sure the\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"wordpress-logo-notext-rgb","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/08\/wordpress-logo-notext-rgb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":191,"url":"https:\/\/pixert.com\/blog\/how-to-add-pinterest-pin-it-to-wordpress\/","url_meta":{"origin":101,"position":5},"title":"How to Add Pinterest &#8220;Pin It&#8221; to WordPress","author":"Pixel Insert \/ Pixert","date":"February 14, 2012","format":false,"excerpt":"Pinterest is a vision board-styled social photo sharing website and app where users can create and manage theme-based image collections. Users of Pinterest curate themed image boards, populating them with media found online using the \"Pin It\" button, or uploaded from their computer. Each such item of media is known\u2026","rel":"","context":"In &quot;WordPress&quot;","block_context":{"text":"WordPress","link":"https:\/\/pixert.com\/blog\/category\/wordpress\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":0,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}