Random Custom Post


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $custom_post = new WP_Query();
  3. $custom_post->query('post_type=testimonial&showposts=1&orderby=rand');
  4. ?>
  5.  
  6. <?php while ($custom_post -> have_posts()) : $custom_post -> the_post(); ?>
  7.  
  8. <div class="post_type">
  9.  
  10. <?php the_content();?>
  11.  
  12. <span class="name right clear">
  13. <?php echo get_post_meta($post->ID, 'custom_post_type_name', $single = true); ?>
  14.  
  15. <?php echo get_post_meta($post->ID, 'custom_post_type_title', $single = true); ?>
  16.  
  17. </span>
  18.  
  19. </div>
  20. <?php endwhile; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.