How to create a multidimensional array with multiple loops
I don’t think this is a restrict WordPress question, but you might try $args = array( ‘posts_per_page’ => ‘-1’, ‘post_type’ => ‘work’, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ); $data = array(‘work’ => array()); $loop = new WP_Query($args); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); $id = $loop->post->ID; $attachments=array(); if(get_field(‘work’)): while(has_sub_field(‘work’)): $attachment_id = get_sub_field(‘image’); $caption … Read more