I'm having problems getting my testimonials to display. On page.php I have a testimonials section. So I have a loop that grabs the content for page.php, and then a get_template_part('content', 'testimonials') to get the testimonial loop.
<div class="grid_12 omega clearfix"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <p><?php the_content(); ?></p> <hr> <?php endwhile; else : ?> <p>There were no posts :( </p> <?php endif; ?> </div> <?php get_template_part( 'content', 'testimonials' ); ?>
So my main loop is up there and looks like that above ^^. My testimonials loop looks like this below in content-testimonials.php:
<?php $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 1, 'orderby' => 'rand' ); $the_query = new WP_Query( $args ); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="testimonial push_2 grid_10 clearfix"> <blockquote>“<?php the_field( 'testimonial' ); ?>”</blockquote> <cite>—<?php the_field( 'name' ); ?></cite> </div> <?php endwhile; else : ?> <p>There were no testimonials :( </p> <?php endif; ?>
I'm still quite new to Wordpress, so I can't see what I'm missing, I've been through the admin area and made sure there were testimonials, edited the custom field to display if the post type is equal to testimonial, I just can't see why it wouldn't load.
I look forward to your responses, thanks in advance!