There is nothing ‘standard’ about a while
loop and in this case it makes things harder, since you need a total count of all the items in loop in order to know if you are on the last item or not. It is not obvious how to get that total count with a function like has_sub_field
but there is a quick way to do this that I use fairly often to build character separated strings when I don’t know how many items will be in the final result.
$attach = array();
while( has_sub_field('images') ):
$image = wp_get_attachment_image_src(get_sub_field('image'), 'wsn_canvas');
$attach[] = $image[0];
endwhile;
echo implode(', ',$attach);
Related Posts:
- ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]
- the_content() seems to block my ACF-code
- How do I go about looping through a advanced custom field on a particular page inside of another page
- Using an ACF field from a page within a post loop?
- ACF custom field in [closed]
- Distribute Gallery Images Every nth in Loop
- ACF – add a group inside a repeater [closed]
- While loop with bootstrap [closed]
- How to create a multidimensional array with multiple loops
- Loop through ACF taxonomies and output associated posts
- Blank content php code not parsing advanced custom fields gallery add-on [closed]
- ACF: display custom filed of CPT into the loop
- Use ACF Category Image for all Taxonomy Archive Views
- Need to while loop and display contents in the subfield of a group field given by ACF
- Add Search and Filter functionality to custom loop
- ACF field not appearing correctly in loop
- Can’t see custom field after the Loop [closed]
- While loop inside another while loop
- ACF loops false value with repeater and checkbox
- Jquery Slider for profile template
- Get excerpt using get_the_excerpt outside a loop
- Should I use loop in the single.php file?
- wp_list_categories: get latest featured_image of category
- WordPress Alphabetical Glossary close div in loop
- as a shortcode within the loop?
- Page template not displaying
- Can I use both a custom excerpt and a trimmed excerpt?
- How to get_template_part using AJAX?
- How can I modify the loop from a plugin without wiping out other filters?
- Complex query and posts pagination
- One custom loop with condition to check child posts
- Loop get_theme_mod
- Move sticky posts down in main loop
- Why only one post (and no pagination) on this variation of the loop?
- Loop in Related Posts WordPress
- Conditional query that displays on Woo product attribute pages
- Template structure
- Custom Loop Using Shortcode in Custom Page Template
- Listing subpages title and content and styling the first iteration differently
- single.php – how to mark current page in the loop
- Cannot retieve the_content() and the_author() – both returning empty strings
- How to order by multiple fields using standard query_posts?
- Get 1 more post in loop
- How to get the excerpt for is_home() outside of the loop isn’t working
- Make loop alphabetical
- How to check if a product is purchased within the last 365 days before displaying something
- How do I get my loop.php to properly paginate?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How to display first post
- Pagination on custom post type on front-page.php
- get_template_part() Not Working in Loop
- get_delete_post_link() inside Loop stubbornly returns nothing
- CPT while loop not working
- Problem with Front-Page.php loading recent posts
- Comments_template doesn’t work
- Get markup for post without loading into the template
- Where to add offset?
- How to synchronize The Loop with the max post per page?
- How to add a byline to all the pages?
- Exclude posts based on an array
- Displaying member join date on page
- Ascending order has strange effects on wordpress loop
- List ALL posts by author on author archive
- get post images to link to external sources
- Using is_page_template inside loop
- ACF – Get ID of relationship field in flexible content
- ACF meta_key and meta_value break loop
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Slug is changing when I use WP_Query in a metabox of a post
- Display related post content and custom field content
- How to execute a user loop with shortcode
- Custom loop not working in singular.php, working in other pages
- Loop Posts Outside of WordPress Installation
- Strange problem with wp_get_attachment_image_src database (db) query count
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- Issue in If else condition [closed]
- Archive sorted by month – separate
- Making a specific page wordpress compatable that is not index
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- Get query result before posts are displayed?
- WordPress Group By Problem
- the_post_thumbnail unless video id is added
- My Query is getting the wrong data
- display only parent replies count in index.php
- using the loop on a page
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- Eliminate duplicates in a foreach loop [closed]
- Tag custom loop show posts
- I want the first post on my home page to be lengthier than the rest (example included)
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- loop mix my child-category and parent-category
- Fix html inside a for loop [closed]
- How can you make it so the comment box shows on some pages or posts but not all?
- Insert multiple custom components after x-number of posts