Support

Account

Home Forums General Issues Fields not always displaying…

Helping

Fields not always displaying…

  • I’ve created a testimonials slider (bootstrap). Almost everything works perfectly, but 2 of the custom fields only appear for the oldest post.

    Here’s my code. Perhaps someone can help me figure out why it’s not working? I would greatly appreciate it. Yes, I have checked to make sure those fields are populated in the other posts.

    <div class="testimonials-container">
    
    <div id="testimonialCarousel" class="carousel slide">
    	
    	<div class="carousel-inner">
    		
    		<?php // Define the query
    		$args = array(
    			'post_type' => 'pixie_testimonial',
    			'post_status' => 'publish',
    			'orderby' => 'ASC',
    			'posts_per_page' => 999,
    		);
    		
    		$tests = new WP_Query( $args );
    		$count = 0;
    	
    		while ($tests->have_posts()) : $tests->the_post();
    			$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'darwin-modal-thumb' );
    			$url = $thumb['0'];
    			//$custom = get_post_custom($post->ID);
    			$job_title = get_field( 'title', $post->ID );
    			$company = get_field( 'company', $post->ID );
    			$company_url = get_field( 'company_url', $post->ID ); ?>
    				
    		<div class="testimonial item<?php if ($count == 0) { echo ' active';} ?>">
    			<figure style="background-image: url('<?php echo $url; ?>');"></figure>
    
    			<p>"<?php the_content(); ?>"</p>
    			<div class="caption">
    				<strong><?php echo get_the_title();
    					if( $job_title ): ?>, <?php echo $job_title; endif; ?>
    				</strong><br>
    				<em>
    					<?php if( $company_url ): ?>
    					<a href="<?php echo $company_url; ?>" target="_blank"> <?php endif;
    						if( $company ): echo $company; endif;
    						
    						if( $company_url ): ?>
    					</a>
    					<?php endif; ?>
    				</em>
    			</div>
    		</div>
    		
    		<?php $count++;
    			endwhile; ?>
    		
        </div>
        
        <a class="carousel-control left" href="#testimonialCarousel" data-slide="prev"><i class="fa fa-angle-left fa-5x"></i></a>
    	<a class="carousel-control right" href="#testimonialCarousel" data-slide="next"><i class="fa fa-angle-right fa-5x"></i></a>
    </div>
    
    </div>
  • I’ve looked at your code a couple of times now, and the only error I can see is in the query args, and I don’t think it would cause a problem.

    
    
    		$args = array(
    			'post_type' => 'pixie_testimonial',
    			'post_status' => 'publish',
                            // should be order
    			//'orderby' => 'ASC',
                            'order' => 'ASC',
    			'posts_per_page' => 999,
    		);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.