jamiehall19
10/9/2018 - 3:56 PM

Random CPT

used for Testimonials

<?php
  $args = array(
    'post_type'=>'testimonials', 
    'orderby'=>'rand', 
    'posts_per_page'=>'1'
  );

  $testimonials=new WP_Query($args);

  while ($testimonials->have_posts()) : $testimonials->the_post(); 
?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <p><?php the_excerpt(); // or the_content(); ?></p>
<?php 
  endwhile;
  wp_reset_postdata();
?>