I've got an archive page for to display custom post types.
Within the WP_Query that displays the custom posts types I want to display an ACF (Advanced Custom Field) or, if the user hasn't filled out the ACF, then the title should appear.
I've tried this and the ACF field displays ok, but when it's not filled out, the title doesn't display, just the content of the post instead.
Here's the code I have (just for the title section):
<?php $loop = new WP_Query( array( 'post_type' => 'project', 'posts_per_page' => -1, 'orderby' => 'menu_order' ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="project col-md-4"> <div class="col-xs-12 short-testimonial"> <?php if(get_field('short_testimonial')): ?> <?php the_field('short_testimonial'); ?> <?php else: ?> <?php echo the_title(); ?> <?php endif; ?> </div>