• Hi there,
    I’m working on a portfolio page with a modal pop up. The portfolio part of the pages is one query in a carousel with a set of posts pulled by meta key (featured item checkbox true), and then the modal includes yet another carousel of all images inside the individual posts displaying in the main portfolio carousel. I may not be explaining this well.

    Anyhow, the problem I’m having is that only the first modal has the associated image/s. All the others are not pulling images, even though they all have at least one. Here’s my code. Any help that can be afforded will be hugely appreciated!

    <?php 	$args = array(
    		'post_type' => 'pixieportfolio',
    		'post_status' => 'publish',
    		'orderby' => 'menu_order',
    		'meta_query'	=> array(
    			array(
    				'key'	  	=> 'featured_portfolio_item',
    				'value'	  	=> '1',
    				'compare' 	=> '=',
    			)
    		),
    		'meta_key' => '_thumbnail_id',
    		'posts_per_page' => 999
    	);
    
    	$query = new WP_Query( $args );
    	$count = 0;
    
    // Carousel // ?>
    <!--<div class="more-button">
    	<a href="/portfolio-all/">More Projects</a>
    </div>-->
    
    <div id="featuredCarousel" class="carousel slide" data-ride="carousel" data-pause="hover">
    
    	<!-- Indicators -->
    	<ol class="carousel-indicators">
    
    		<?php while($query->have_posts()): $query->the_post(); ?>
    
                <li <?php if($count == 0){ echo 'class="active"';} ?> data-target="#featuredCarousel" data-slide-to="<?php echo $count++; ?>">
    
              <?php endwhile;  wp_reset_postdata(); ?>
    
    	<div class="carousel-inner" role="listbox">
    
    		<?php $count = 0;
    
    			while ($query->have_posts()) : $query->the_post();
    			$count++;
    			$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'pp-home-portfolio' );
    			$url = $thumb['0'];
    			$values = get_field('tech_choices');
    			$terms = get_the_terms($post->ID, 'post_tag');
    			$custom = get_post_custom($post->ID); ?>
    
    		<!-- Wrapper for slides -->
    		<div class="item <?php if ($count == 1) { echo 'active';} ?>" data-slide-number="<?php echo $count++; ?>" id="<? the_ID(); ?>">
    			<a>" title="<?php the_title() ?>" data-toggle="tooltip">
    				<div class="item-image" style="background-image: url(<?=$url?>);" title="<?php the_title() ?>"></div>
    			</a>
    
    			<div class="project-details">
    				<div class="project-detail-border shadow-effect"></div>
    				<div class="project-detail">
    					<div class="top-detail">
    						<h4><?php the_title(); ?></h4>
    						<div class="short-description">
    							<?php $content = get_the_content();
    								echo wp_trim_words( $content , '25' );
    							?>
    						</div>
    					</div>
    
    					<table class="table project">
    						<tr>
    								<td valign="middle" class="fifty">
    									<?php $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'pixie-portfolio-categories', '', ', ', '' ) );
    echo $terms_as_text;?>
    								</td>
    
    								<td valign="middle" class="fifty">
    
    										TECH GOES HERE
    
    								</td>
    							</tr>
    
    							<tr>
    								<td colspan="2" class="more-info" data-toggle="modal" data-target="#myModal<?php echo $count; ?>">
    									<div class="view-project">View Project</div>
    								</td>
    							</tr>
    					</table>
    				</div>
    			</div>
    		</div>
    
    		<!-- Modal -->
    		<div id="myModal<?php echo $count; ?>" class="modal fade" role="dialog" aria-labelledby="myModal<?php echo $count++; ?>Label">
    			<div class="modal-dialog modal-lg" role="document">
    
    				<!-- Modal content-->
    				<div class="modal-content">
    					<div class="modal-header">
    						<button type="button" class="close" data-dismiss="modal">×</button>
    						<h2 class="modal-title"><?php the_title() ?></h2>
    						<span>
    							<?php if( $terms ): ?>
    
    <ul>
    								<?php foreach( $terms as $term ): ?>
    
    <li><a>"><?php echo $term->name; ?></a></li>
    								<?php $icon = get_field('creative_icon', $term->taxonomy . '_' . $term->term_id); echo $icon; ?>
    								<?php endforeach; ?>
    							</ul>
    							<?php endif; ?>
    						</span>
    					</div>
    					<div class="modal-body">
    						<div class="container-fluid">
    							<div class="row">
    								<div class="col-md-7">
    									<div>
    										<?php if( $client):?>Client Name: <?php echo $client; endif; if( $project_url): ?>| <a>" target="_blank">Visit Website</a><?php endif; if( $project_date): ?> | Project Date: <?php echo $project_date; endif;?>
    									</div>
    
    									<?php echo the_content(); ?>
    
    <blockquote>
    										quote goes here
    
    </blockquote>
    								</div>
    
    								<div class="col-md-5">
    									<div class="carousel slide article-slide" id="projectCarousel">
    										<div class="carousel-inner cont-slider">
    											<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size = 'darwin-featured' );
    											$url = $thumb['0'];
    											$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
    											$images = get_field('gallery_images');
    											?>
    											<div class="item active" style="background-image: url(<?php echo $url; ?>);">
    											</div>
    											<?php if( $images ): foreach( $images as $image ): ?>
    											<div class="item">
    												<img src="<?php echo $image['sizes']['darwin-featured']; ?>" />
    											</div>
    										<?php endforeach; endif; ?>
    										</div>
    
    										<!-- Indicators -->
    										<ol class="carousel-indicators visible-lg visible-md">
    											<li class="active" data-slide-to="0" data-target="#projectCarousel">
    												<img alt="" title="" src="<?php echo $url?>">
    
    											<?php if( $images ): foreach( $images as $image ): ?>
    											<li class="" data-slide-to="1" data-target="#projectCarousel">
    												<img alt="" title="" src="<?php echo $image['sizes']['darwin-featured']; ?>">
    
    											<?php endforeach; endif; ?>
    
    									</div>
    								</div>
    							</div>
    						</div>
    					</div>
    					<div class="modal-footer">
    						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    					</div>
    				</div>
    			</div>
    		</div>
    
    		<?php endwhile; wp_reset_postdata();
    ?>
  • The topic ‘Having difficulty with a nested query using ACF’ is closed to new replies.