Home › Forums › General Issues › 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,
);
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
📣 “ACF Chat Fridays”
— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.