Back

Foreach on WP Query WordPress

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'media_picture', 'orderby' => 'date', 'order' => 'DESC', 'showposts' => 40, 'no_rows_found' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'paged' => $paged ); $loop = new WP_Query($args); $posts = $loop->posts; // echo "<pre>"; print_r($posts); exit; if( $posts ) { ?> <?php foreach($posts as $post) { $post_id = $post->ID; $imageUrl =get_field('file', $post_id)['url']; ?> <?php include('template-parts/photos-single-item.php'); ?> <?php } // Foreach END } // if END ?>